<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="description" content="Linux文件与目录管理"/>
    <meta name="keywords"
          content="nginx,freebsd,linux,mysql,shell,apache,centos,redhat,rhel,windows,sql,系统运维,IT运维,开源系统,开源系统运维"/>
    <title> Linux文件与目录管理 </title>

</head>
<body bgcolor="#FFFFFF" text="#000000">
<div id="menu">
    <ul>
		<span style="FONT-SIZE: 10.5pt">

			<li><a href="index.htm" hidefocus="true" id="mn_list">linux入门教程</a></li>

		</span>
    </ul>
</div>
<p style="text-align: center;margin-right: 21pt;"><span style="font-family:'宋体';font-size:15pt;"><b>第六章</b></span><span
        style="font-family:'Calibri';font-size:15pt;"><b> Linux</b></span><span
        style="font-family:'宋体';font-size:15pt;"><b>文件与目录管理</b></span></p>
<p style="text-align: justify;text-indent: 18pt;"><span style="font-family:'宋体';font-size:10.5pt;">在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">中什么是一个文件的路径呢，说白了就是这个文件存在的地方，例如在上一章提到的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/root/.ssh/authorized_keys </span><span
        style="font-family:'宋体';font-size:10.5pt;">这就是一个文件的路径</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">如果你告诉系统这个文件的路径，那么系统就可以找到这个文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">的世界中，存在着绝对路径和相对路径</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>


<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;"><b>绝对路径</b></span><span
        style="font-family:'宋体';font-size:10.5pt;">：路径的写法一定由根目录</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”/”</span><span
        style="font-family:'宋体';font-size:10.5pt;">写起，例如</span><span style="font-family:'Calibri';font-size:10.5pt;">/usr/local/mysql </span><span
        style="font-family:'宋体';font-size:10.5pt;">这就是绝对路径</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;"><b>相对路径</b></span><span
        style="font-family:'宋体';font-size:10.5pt;">：路径的写法不是由根目录</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”/”</span><span style="font-family:'宋体';font-size:10.5pt;">写起，例如，首先用户进入到</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/ </span><span
        style="font-family:'宋体';font-size:10.5pt;">然后再进入到</span><span style="font-family:'Calibri';font-size:10.5pt;">home </span><span
        style="font-family:'宋体';font-size:10.5pt;">，命令为</span><span style="font-family:'Calibri';font-size:10.5pt;"> cd /home  </span><span
        style="font-family:'宋体';font-size:10.5pt;">然后</span><span style="font-family:'Calibri';font-size:10.5pt;"> cd  test </span><span
        style="font-family:'宋体';font-size:10.5pt;">此时用户所在的路径为</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> /home/test 。</span><span
        style="font-family:'宋体';font-size:10.5pt;">第一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">cd</span><span
        style="font-family:'宋体';font-size:10.5pt;">命令后跟</span><span style="font-family:'Calibri';font-size:10.5pt;"> /home  </span><span
        style="font-family:'宋体';font-size:10.5pt;">第二个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">cd</span><span
        style="font-family:'宋体';font-size:10.5pt;">命令后跟</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test </span><span style="font-family:'宋体';font-size:10.5pt;">，并没有斜杠，这个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test</span><span
        style="font-family:'宋体';font-size:10.5pt;">是相对于</span><span style="font-family:'Calibri';font-size:10.5pt;">/home </span><span
        style="font-family:'宋体';font-size:10.5pt;">目录来讲的，所以叫做相对路径</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>pwd</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span style="font-family:'宋体';font-size:10.5pt;">这个命令打印出当前所在目录</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_1.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>cd </b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span style="font-family:'宋体';font-size:10.5pt;">进入到某一个目录</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_12.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">./ </span><span
        style="font-family:'宋体';font-size:10.5pt;">指的是当前目录</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">../ </span><span
        style="font-family:'宋体';font-size:10.5pt;">指的是当前目录的上一级目录</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_13.png"></span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'宋体';font-size:10.5pt;">上图中，首先进入到</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/usr/local/lib/ </span><span
        style="font-family:'宋体';font-size:10.5pt;">目录下，然后再进入</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> ./ </span><span style="font-family:'宋体';font-size:10.5pt;">其实还是进入到当前目录下，用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">pwd</span><span style="font-family:'宋体';font-size:10.5pt;">查看当前目录，并没有发生变化，然后再进入</span><span
        style="font-family:'Calibri';font-size:10.5pt;">../ </span><span style="font-family:'宋体';font-size:10.5pt;">则是进入到了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/usr/local/</span><span
        style="font-family:'宋体';font-size:10.5pt;">目录下，即</span><span style="font-family:'Calibri';font-size:10.5pt;">/usr/local/lib</span><span
        style="font-family:'宋体';font-size:10.5pt;">目录的上一级目录</span><span style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">你看明白了吗？</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>mkdir</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;">  </span><span style="font-family:'宋体';font-size:10.5pt;">创建一个目录，这个命令在上一章节中提及过</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。mkdir </span><span style="font-family:'宋体';font-size:10.5pt;">其实就是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">make directory</span><span
        style="font-family:'宋体';font-size:10.5pt;">的缩写</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">其语法为</span><span style="font-family:'Calibri';font-size:10.5pt;"> mkdir [-mp] [</span><span
        style="font-family:'宋体';font-size:10.5pt;">目录名称</span><span
        style="font-family:'Calibri';font-size:10.5pt;">] </span><span
        style="font-family:'宋体';font-size:10.5pt;">，其中</span><span style="font-family:'Calibri';font-size:10.5pt;">-m , –p </span><span
        style="font-family:'宋体';font-size:10.5pt;">为其选项，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">-m</span><span style="font-family:'宋体';font-size:10.5pt;">：这个参数用来指定要创建目录的权限，该参数不常用，所以笔者不做重点解释</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。-p</span><span style="font-family:'宋体';font-size:10.5pt;">：这个参数很管用的，先来做个试验，你会一目了然的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;"><img
        src="6_14.png"></span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'宋体';font-size:10.5pt;">当我们想创建</span><span
        style="font-family:'Calibri';font-size:10.5pt;">  /tmp/test/123 </span><span
        style="font-family:'宋体';font-size:10.5pt;">目录，可是提示不能创建，原因是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/tmp/test</span><span
        style="font-family:'宋体';font-size:10.5pt;">目录不存在，你会说，这个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">怎么这样傻，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/tmp/test</span><span
        style="font-family:'宋体';font-size:10.5pt;">目录不存在就自动创建不就</span><span
        style="font-family:'Calibri';font-size:10.5pt;">OK</span><span
        style="font-family:'宋体';font-size:10.5pt;">了嘛，的确</span><span style="font-family:'Calibri';font-size:10.5pt;">linux</span><span
        style="font-family:'宋体';font-size:10.5pt;">确实很傻，如果它发现要创建的目录的上一级目录不存在就会报错</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">然后</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">也为我们想好了解决办法，即</span><span
        style="font-family:'Calibri';font-size:10.5pt;">-p</span><span
        style="font-family:'宋体';font-size:10.5pt;">参数</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;"><img
        src="6_15.png"></span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'宋体';font-size:10.5pt;">你看到这里，是不是明白</span><span
        style="font-family:'Calibri';font-size:10.5pt;">-p</span><span style="font-family:'宋体';font-size:10.5pt;">参数的作用了？没错，它的作用就是递归创建目录，即使上级目录不存在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">还有一种情况就是如果你想要创建的目录存在的话，会提示报错，然后你加上</span><span
        style="font-family:'Calibri';font-size:10.5pt;">-p</span><span style="font-family:'宋体';font-size:10.5pt;">参数后，就不会报错了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;"><img
        src="6_16.png"></span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>rmdir</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;">  </span><span
        style="font-family:'宋体';font-size:10.5pt;">删除一个目录</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。 </span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;"><img
        src="6_17.png"></span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">rmdir </span><span style="font-family:'宋体';font-size:10.5pt;">其实是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rmove directory </span><span
        style="font-family:'宋体';font-size:10.5pt;">缩写，其只有一个选项</span><span
        style="font-family:'Calibri';font-size:10.5pt;">-p </span><span
        style="font-family:'宋体';font-size:10.5pt;">类似与</span><span
        style="font-family:'Calibri';font-size:10.5pt;">mkdir</span><span style="font-family:'宋体';font-size:10.5pt;">命令，这个参数的作用是将上级目录一起删除</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">举个例子吧，新建目录</span><span
        style="font-family:'Calibri';font-size:10.5pt;">mkdir -p d1/d2/d3 </span><span
        style="font-family:'宋体';font-size:10.5pt;">，</span><span style="font-family:'Calibri';font-size:10.5pt;">rmdir -p d1/d2/d3</span><span
        style="font-family:'宋体';font-size:10.5pt;">相当于是删除了</span><span style="font-family:'Calibri';font-size:10.5pt;">d1,d1/d2, d1/d2/d3。</span><span
        style="font-family:'宋体';font-size:10.5pt;">如果一个目录中还有目录，那么当你直接</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rmdir </span><span style="font-family:'宋体';font-size:10.5pt;">该目录时，会提示该目录不为空，不能删除</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">如果你非要删除不为空的目录，那你用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rm</span><span
        style="font-family:'宋体';font-size:10.5pt;">指令吧</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>rm</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;">  </span><span style="font-family:'宋体';font-size:10.5pt;">删除目录或者文件</span>
</p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">	rmdir </span><span
        style="font-family:'宋体';font-size:10.5pt;">只能删除目录但不能删除文件，要想删除一个文件，则要用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rm</span><span
        style="font-family:'宋体';font-size:10.5pt;">命令了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。rm</span><span style="font-family:'宋体';font-size:10.5pt;">同样也有很多选项</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">你可以通过</span><span style="font-family:'Calibri';font-size:10.5pt;"> man rm </span><span
        style="font-family:'宋体';font-size:10.5pt;">来获得详细帮助信息</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">在这里笔者只列举较常用的几个选项</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">-f  </span><span style="font-family:'宋体';font-size:10.5pt;">强制的意思，如果不加这个选项，当删除一个不存在的文件时会报错</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;"><img
        src="6_18.png"></span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">-i  </span><span style="font-family:'宋体';font-size:10.5pt;">这个选项的作用是，当用户删除一个文件时会提示用户是否真的删除</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;"><img
        src="6_19.png"></span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'宋体';font-size:10.5pt;">如果删除，输入</span><span
        style="font-family:'Calibri';font-size:10.5pt;">y </span><span
        style="font-family:'宋体';font-size:10.5pt;">否则输入</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> n</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">-r  </span><span style="font-family:'宋体';font-size:10.5pt;">当删除目录时，加该选项，如果不加这个选项会报错</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。rm</span><span style="font-family:'宋体';font-size:10.5pt;">是可以删除不为空的目录的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;"><img
        src="6_20.png"></span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'宋体';font-size:10.5pt;">你会发现，笔者在列举的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rm</span><span style="font-family:'宋体';font-size:10.5pt;">例子中使用的是绝对路径，而</span><span
        style="font-family:'Calibri';font-size:10.5pt;">ls </span><span style="font-family:'宋体';font-size:10.5pt;">则使用的相对路径</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">这是为什么呢？</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;"><img
        src="6_21.png"></span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>which </b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span style="font-family:'宋体';font-size:10.5pt;">用来查找一个命令的绝对路径，这个命令笔者不详细介绍，因为平时笔者只用来查找一个命令的绝对路径</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>alias</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;">  </span><span
        style="font-family:'宋体';font-size:10.5pt;">用来</span><span
        style="font-family:'宋体';font-size:10.5pt; color:#000000;">设置指令的别名</span><span
        style="font-family:'Arial';font-size:10.5pt; color:#000000;">。</span><span
        style="font-family:'宋体';font-size:10.5pt; color:#000000;">语法：</span><span
        style="font-family:'Arial';font-size:10.5pt; color:#000000;">alias[</span><span
        style="font-family:'宋体';font-size:10.5pt; color:#000000;">别名</span><span
        style="font-family:'Arial';font-size:10.5pt; color:#000000;">]=[</span><span
        style="font-family:'宋体';font-size:10.5pt; color:#000000;">指令名称</span><span
        style="font-family:'Arial';font-size:10.5pt; color:#000000;">]</span><span
        style="font-family:'宋体';font-size:10.5pt; color:#000000;">，例如</span><span
        style="font-family:'Arial';font-size:10.5pt; color:#000000;"> alias rm='rm -i' </span><span
        style="font-family:'宋体';font-size:10.5pt; color:#000000;">，即当我们使用</span><span
        style="font-family:'Arial';font-size:10.5pt; color:#000000;">rm</span><span
        style="font-family:'宋体';font-size:10.5pt; color:#000000;">命令时，实际上是使用的是</span><span
        style="font-family:'Arial';font-size:10.5pt; color:#000000;">rm –i </span><span
        style="font-family:'宋体';font-size:10.5pt; color:#000000;">，而用绝对路径的</span><span
        style="font-family:'Arial';font-size:10.5pt; color:#000000;">/bin/rm </span><span
        style="font-family:'宋体';font-size:10.5pt; color:#000000;">则不会被</span><span
        style="font-family:'Arial';font-size:10.5pt; color:#000000;">alias</span><span
        style="font-family:'宋体';font-size:10.5pt; color:#000000;">，该命令在以后章节中会详细介绍</span><span
        style="font-family:'Arial';font-size:10.5pt; color:#000000;">。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;">【</span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>环境变量</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>PATH】</b></span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">	</span><span style="font-family:'宋体';font-size:10.5pt;">上边提到了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">alias</span><span style="font-family:'宋体';font-size:10.5pt;">，也提到了绝对路径的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/bin/rm </span><span style="font-family:'宋体';font-size:10.5pt;">，然后你意识到没有，为什么我们输入很多命令时是直接打出了命令，而没有去使用这些命令的绝对路径？这是因为环境变量</span><span
        style="font-family:'Calibri';font-size:10.5pt;">PATH</span><span style="font-family:'宋体';font-size:10.5pt;">在起作用了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">请输入</span><span style="font-family:'Calibri';font-size:10.5pt;"> echo $PATH</span><span
        style="font-family:'宋体';font-size:10.5pt;">，这里的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">echo</span><span style="font-family:'宋体';font-size:10.5pt;">其实就是打印的意思，而</span><span
        style="font-family:'Calibri';font-size:10.5pt;">PATH</span><span
        style="font-family:'宋体';font-size:10.5pt;">前面的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">$</span><span style="font-family:'宋体';font-size:10.5pt;">表示后面接的是变量</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;"><img
        src="6_65.png"></span></p>
<p style="text-align: justify;text-indent: 21pt;margin-right: 21pt;"><span
        style="font-family:'宋体';font-size:10.5pt;">因为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/bin </span><span
        style="font-family:'宋体';font-size:10.5pt;">在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">PATH</span><span style="font-family:'宋体';font-size:10.5pt;">的设定中，所以自然就可以找到</span><span
        style="font-family:'Calibri';font-size:10.5pt;">ls</span><span
        style="font-family:'宋体';font-size:10.5pt;">了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">如果你将</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> ls </span><span
        style="font-family:'宋体';font-size:10.5pt;">移动到</span><span style="font-family:'Calibri';font-size:10.5pt;"> /root </span><span
        style="font-family:'宋体';font-size:10.5pt;">底下的话，然后你自己本身也在</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> /root </span><span style="font-family:'宋体';font-size:10.5pt;">底下，但是当你执行</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> ls </span><span style="font-family:'宋体';font-size:10.5pt;">的时候，他就是不理你？怎么办？这是因为</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> PATH </span><span
        style="font-family:'宋体';font-size:10.5pt;">没有</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> /root </span><span style="font-family:'宋体';font-size:10.5pt;">这个目录，而你又将</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> ls </span><span
        style="font-family:'宋体';font-size:10.5pt;">移动到</span><span style="font-family:'Calibri';font-size:10.5pt;"> /root </span><span
        style="font-family:'宋体';font-size:10.5pt;">底下了，自然系统就找不到可执行文件了，因此就会告诉你，</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> command not found </span><span
        style="font-family:'宋体';font-size:10.5pt;">！那么该怎么克服这种问题呢？</span></p>
<p style="text-align: justify;text-indent: 21pt;margin-right: 21pt;"><span style="font-family:'宋体';font-size:10.5pt;">有两个方法，一种方法是直接将</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> /root </span><span style="font-family:'宋体';font-size:10.5pt;">的路径加入</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> PATH </span><span style="font-family:'宋体';font-size:10.5pt;">当中！如何增加？可以使用：</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> 　 </span></p>
<p style="text-align: justify;text-indent: 21pt;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">PATH=”$PATH”:/root</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'宋体';font-size:10.5pt;">另一种方式则是使用完整档名，亦即直接使用相对或绝对路径来执行，例如：</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">/root/ls </span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;">./ls</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">关于</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rm</span><span style="font-family:'宋体';font-size:10.5pt;">，笔者使用最多便是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">-rf</span><span style="font-family:'宋体';font-size:10.5pt;">两个选项合用了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">不管删除文件还是目录都可以</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">但是方便的同时也要多注意，万一你的手太快后边跟了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/</span><span style="font-family:'宋体';font-size:10.5pt;">那样就会把你的系统文件全部删除的，切记切记</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;"><img
        src="6_66.png"></span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>ls </b></span><span
        style="font-family:'宋体';font-size:10.5pt;">在前面的命令中多次用到它</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">现在你已经明白它的含义了吧</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">没有错，就是查看某个目录或者某个文件，是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">list</span><span
        style="font-family:'宋体';font-size:10.5pt;">的简写</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。ls </span><span style="font-family:'宋体';font-size:10.5pt;">后可以跟一个目录，也可以跟一个文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">以下是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">ls</span><span style="font-family:'宋体';font-size:10.5pt;">的选项，在这里笔者并没有完全列出，只是列出了平时使用最多的选项</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">其他选项，你可以自行通过</span><span
        style="font-family:'Calibri';font-size:10.5pt;">man  ls </span><span style="font-family:'宋体';font-size:10.5pt;">查询</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">-a  </span><span style="font-family:'宋体';font-size:10.5pt;">全部的档案都列出，包括隐藏的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。linux</span><span style="font-family:'宋体';font-size:10.5pt;">文件系统中同样也有隐藏文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">这些隐藏文件的文件名是以</span><span
        style="font-family:'Calibri';font-size:10.5pt;">.</span><span
        style="font-family:'宋体';font-size:10.5pt;">开头的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">例如</span><span style="font-family:'Calibri';font-size:10.5pt;">.test, /root/.123, /root/.ssh </span><span
        style="font-family:'宋体';font-size:10.5pt;">等等，隐藏文件可以是目录也可以是普通文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">-l  </span><span style="font-family:'宋体';font-size:10.5pt;">详细列出文件的属性信息，包括大小</span><span
        style="font-family:'Calibri';font-size:10.5pt;">、</span><span
        style="font-family:'宋体';font-size:10.5pt;">创建日期</span><span
        style="font-family:'Calibri';font-size:10.5pt;">、</span><span style="font-family:'宋体';font-size:10.5pt;">所属主所属组等等</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。ll </span><span style="font-family:'宋体';font-size:10.5pt;">这个命令等同于</span><span
        style="font-family:'Calibri';font-size:10.5pt;">ls –l 。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;"><img
        src="6_67.png"></span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;">--color=never/always/auto  never</span><span
        style="font-family:'宋体';font-size:10.5pt;">即不要显示颜色，</span><span style="font-family:'Calibri';font-size:10.5pt;">always </span><span
        style="font-family:'宋体';font-size:10.5pt;">即总显示颜色，</span><span style="font-family:'Calibri';font-size:10.5pt;">auto </span><span
        style="font-family:'宋体';font-size:10.5pt;">是由系统自行判断</span><span style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">在</span><span style="font-family:'Calibri';font-size:10.5pt;">Redhat/CentOS </span><span
        style="font-family:'宋体';font-size:10.5pt;">系统中，默认是带颜色的，因为我们平时用的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">ls</span><span
        style="font-family:'宋体';font-size:10.5pt;">已经</span><span
        style="font-family:'Calibri';font-size:10.5pt;">alias</span><span
        style="font-family:'宋体';font-size:10.5pt;">成了</span><span style="font-family:'Calibri';font-size:10.5pt;">ls –color=tty </span><span
        style="font-family:'宋体';font-size:10.5pt;">所以目录的颜色是蓝色的，而可执行文件的颜色是绿色</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">这样有助于帮我们区分文件的格式</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;"><img
        src="6_68.png"></span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">-d  </span><span style="font-family:'宋体';font-size:10.5pt;">后边跟目录，如果不加这个选项则列出目录下的文件，加上后只列车目录本身</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;"><img
        src="6_69.png"></span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>cp</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;">  copy</span><span style="font-family:'宋体';font-size:10.5pt;">的简写，即拷贝</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">格式为</span><span style="font-family:'Calibri';font-size:10.5pt;">  cp  [</span><span
        style="font-family:'宋体';font-size:10.5pt;">选项</span><span
        style="font-family:'Calibri';font-size:10.5pt;">]  [ </span><span style="font-family:'宋体';font-size:10.5pt;">来源文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> ] [</span><span
        style="font-family:'宋体';font-size:10.5pt;">目的文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">] </span><span
        style="font-family:'宋体';font-size:10.5pt;">，例如我想把</span><span style="font-family:'Calibri';font-size:10.5pt;">test1 </span><span
        style="font-family:'宋体';font-size:10.5pt;">拷贝成</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test2 </span><span style="font-family:'宋体';font-size:10.5pt;">，这样即可</span><span
        style="font-family:'Calibri';font-size:10.5pt;">  cp  test1  test2</span><span
        style="font-family:'宋体';font-size:10.5pt;">，以下介绍几个常用的选项</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">-d  </span><span style="font-family:'宋体';font-size:10.5pt;">这里涉及到一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">“</span><span
        style="font-family:'宋体';font-size:10.5pt;">连接</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”</span><span
        style="font-family:'宋体';font-size:10.5pt;">的概念</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">连接分为软连接和硬连接</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">在以后的章节中会详细解释，现在你只要明白这里的软连接跟</span><span
        style="font-family:'Calibri';font-size:10.5pt;">windows</span><span style="font-family:'宋体';font-size:10.5pt;">中的快捷方式类似即可</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">如果不加这个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">-d </span><span style="font-family:'宋体';font-size:10.5pt;">则拷贝软连接时会把软连接的目标文件拷贝过去，而加上后，其实只是拷贝了一个连接文件（即快捷方式）</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;"><img
        src="6_70.png"></span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'宋体';font-size:10.5pt;">上例中的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">ln </span><span style="font-family:'宋体';font-size:10.5pt;">命令即为建立连接的，以后再做详细解释</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;">-r </span><span
        style="font-family:'宋体';font-size:10.5pt;">如果你要拷贝一个目录，必须要加</span><span
        style="font-family:'Calibri';font-size:10.5pt;">-r</span><span style="font-family:'宋体';font-size:10.5pt;">选项，否则你是拷贝不了目录的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;"><img
        src="6_71.png"></span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;">-i </span><span
        style="font-family:'宋体';font-size:10.5pt;">如果遇到一个存在的文件，会问是否覆盖</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">在</span><span style="font-family:'Calibri';font-size:10.5pt;">Redhat/CentOS</span><span
        style="font-family:'宋体';font-size:10.5pt;">系统中，我们使用的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">cp</span><span
        style="font-family:'宋体';font-size:10.5pt;">其实是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">cp –i</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;"><img
        src="6_72.png"></span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'宋体';font-size:10.5pt;">下面简单做一个小试验，很快你就会明白</span><span
        style="font-family:'Calibri';font-size:10.5pt;">-i </span><span style="font-family:'宋体';font-size:10.5pt;">选项的作用了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;"><img
        src="6_73.png"></span></p>
<p style="text-align: justify;text-indent: 21pt;margin-right: 21pt;"><span style="font-family:'宋体';font-size:10.5pt;">上例中，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">touch </span><span style="font-family:'宋体';font-size:10.5pt;">命令，看字面意思就是摸一下，没错，如果有这个文件，则会改变文件的访问时间，如果没有这个文件就会创建这个文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">前面说过</span><span
        style="font-family:'Calibri';font-size:10.5pt;">echo</span><span style="font-family:'宋体';font-size:10.5pt;">，其实就是打印，在这里所</span><span
        style="font-family:'Calibri';font-size:10.5pt;">echo</span><span
        style="font-family:'宋体';font-size:10.5pt;">的内容</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”abc” </span><span
        style="font-family:'宋体';font-size:10.5pt;">和</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> “def”</span><span style="font-family:'宋体';font-size:10.5pt;">并没有显示在屏幕上，而是分别写进了文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> 111</span><span
        style="font-family:'宋体';font-size:10.5pt;">和</span><span
        style="font-family:'Calibri';font-size:10.5pt;">222, </span><span style="font-family:'宋体';font-size:10.5pt;">其写入作用的就是这个大于号</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”&gt;” </span><span
        style="font-family:'宋体';font-size:10.5pt;">在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">中这叫做重定向，即把前面产生的输出写入到后面的文件中</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">在以后的章节中会做详细介绍，这里你要明白它的含义即可</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">而</span><span
        style="font-family:'Calibri';font-size:10.5pt;">cat </span><span style="font-family:'宋体';font-size:10.5pt;">命令则是读一个文件，并把读出的内容打印到当前屏幕上</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">该命令也会在后续章节中详细介绍</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">-u  </span><span style="font-family:'宋体';font-size:10.5pt;">该选项仅当目标文件存在时才会生效，如果源文件比目标文件新才会拷贝，否则不做任何动作</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>mv </b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span
        style="font-family:'宋体';font-size:10.5pt;">移动的意思，是</span><span style="font-family:'Calibri';font-size:10.5pt;">move</span><span
        style="font-family:'宋体';font-size:10.5pt;">的简写</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">格式为</span><span style="font-family:'Calibri';font-size:10.5pt;"> mv  [ </span><span
        style="font-family:'宋体';font-size:10.5pt;">选项</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> ] [</span><span
        style="font-family:'宋体';font-size:10.5pt;">源文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">] [</span><span
        style="font-family:'宋体';font-size:10.5pt;">目标文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">]</span><span style="font-family:'宋体';font-size:10.5pt;">，下面介绍几个常用的选项</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">-i  </span><span
        style="font-family:'宋体';font-size:10.5pt;">和</span><span
        style="font-family:'Calibri';font-size:10.5pt;">cp</span><span
        style="font-family:'宋体';font-size:10.5pt;">的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">-i </span><span style="font-family:'宋体';font-size:10.5pt;">一样，当目标文件存在时会问用户是否要覆盖</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">在</span><span style="font-family:'Calibri';font-size:10.5pt;">Redhat/CentOS</span><span
        style="font-family:'宋体';font-size:10.5pt;">系统中，我们使用的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">mv</span><span
        style="font-family:'宋体';font-size:10.5pt;">其实是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">mv –i</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">-u  </span><span
        style="font-family:'宋体';font-size:10.5pt;">和上边</span><span
        style="font-family:'Calibri';font-size:10.5pt;">cp </span><span
        style="font-family:'宋体';font-size:10.5pt;">命令的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">-u</span><span style="font-family:'宋体';font-size:10.5pt;">选项一个作用，当目标文件存在时才会生效，如果源文件比目标文件新才会移动，否则不做任何动作</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;text-indent: 21pt;margin-right: 21pt;"><span style="font-family:'宋体';font-size:10.5pt;">该命令有集中情况，你注意到了吗？</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span></p>
<p style="text-align: justify;text-indent: 21pt;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">1</span><span
        style="font-family:'宋体';font-size:10.5pt;">）</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span style="font-family:'宋体';font-size:10.5pt;">目标文件是目录，而且目标文件不存在；</span>
</p>
<p style="text-align: justify;text-indent: 21pt;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">2</span><span
        style="font-family:'宋体';font-size:10.5pt;">）</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span style="font-family:'宋体';font-size:10.5pt;">目标文件是目录，而且目标文件存在；</span>
</p>
<p style="text-align: justify;text-indent: 21pt;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">3</span><span
        style="font-family:'宋体';font-size:10.5pt;">）</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span style="font-family:'宋体';font-size:10.5pt;">目标文件不是目录不存在；</span>
</p>
<p style="text-align: justify;text-indent: 21pt;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">4</span><span
        style="font-family:'宋体';font-size:10.5pt;">）</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span style="font-family:'宋体';font-size:10.5pt;">目标文件不是目录存在；</span>
</p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">	</span><span style="font-family:'宋体';font-size:10.5pt;">目标文件是目录，存在和不存在，移动的结果是不一样的，如果存在，则会把源文件移动到目标文件目录中</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">不存在的话移动完后，目标文件是一个文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">这样说也许你会觉得有点不好理解，看例子吧</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;margin-right: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;"><img
        src="6_74.png"></span></p>
<p style="text-align: justify;margin-right: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">windows</span><span style="font-family:'宋体';font-size:10.5pt;">下的重命名，在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span
        style="font-family:'宋体';font-size:10.5pt;">下用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">mv</span><span
        style="font-family:'宋体';font-size:10.5pt;">就可以搞定</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>cat </b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span style="font-family:'宋体';font-size:10.5pt;">比较常用的一个命令，即查看一个文件的内容并显示在屏幕上</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">-n  </span><span
        style="font-family:'宋体';font-size:10.5pt;">查看文件时，把行号也显示到屏幕上</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_75.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">上例中出现了一个</span><span style="font-family:'Calibri';font-size:10.5pt;">”&gt;&gt;”</span><span
        style="font-family:'宋体';font-size:10.5pt;">，这个符号跟前面介绍的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”&gt;”</span><span style="font-family:'宋体';font-size:10.5pt;">的作用都是重定向，即把前面输出的东西输入到后边的文件中，只是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”&gt;&gt;”</span><span
        style="font-family:'宋体';font-size:10.5pt;">是追加的意思，而用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”&gt;”</span><span style="font-family:'宋体';font-size:10.5pt;">，如果文件中有内容则会删除文件中内容，而</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”&gt;&gt;”</span><span
        style="font-family:'宋体';font-size:10.5pt;">则不会</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">-A  </span><span
        style="font-family:'宋体';font-size:10.5pt;">显示所有东西出来，包括特殊字符</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_76.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>tac</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;">  </span><span
        style="font-family:'宋体';font-size:10.5pt;">其实是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">cat</span><span style="font-family:'宋体';font-size:10.5pt;">的反写，同样的功能也是反向打印文件的内容到屏幕上</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_77.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>more</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span style="font-family:'宋体';font-size:10.5pt;">也是用来查看一个文件的内容</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">当文件内容太多，一屏幕不能占下，而你用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">cat</span><span style="font-family:'宋体';font-size:10.5pt;">肯定是看不前面的内容的，那么使用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">more</span><span style="font-family:'宋体';font-size:10.5pt;">就可以解决这个问题了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">当看完一屏后按空格键继续看下一屏</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">但看完所有内容后就会退出</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">如果你想提前退出，只需按</span><span
        style="font-family:'Calibri';font-size:10.5pt;">q</span><span
        style="font-family:'宋体';font-size:10.5pt;">键即可</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>less</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span
        style="font-family:'宋体';font-size:10.5pt;">作用跟</span><span
        style="font-family:'Calibri';font-size:10.5pt;">more</span><span style="font-family:'宋体';font-size:10.5pt;">一样，但比</span><span
        style="font-family:'Calibri';font-size:10.5pt;">more</span><span style="font-family:'宋体';font-size:10.5pt;">好在可以上翻，下翻</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">空格键同样可以翻页，而按</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”j”</span><span style="font-family:'宋体';font-size:10.5pt;">键可以向下移动（按一下就向下移动一行），按</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”k”</span><span
        style="font-family:'宋体';font-size:10.5pt;">键向上移动</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">在使用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">more</span><span
        style="font-family:'宋体';font-size:10.5pt;">和</span><span
        style="font-family:'Calibri';font-size:10.5pt;">less</span><span style="font-family:'宋体';font-size:10.5pt;">查看某个文件时，你可以按一下</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”/” </span><span style="font-family:'宋体';font-size:10.5pt;">键，然后输入一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">word</span><span style="font-family:'宋体';font-size:10.5pt;">回车，这样就可以查找这个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">word</span><span
        style="font-family:'宋体';font-size:10.5pt;">了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">如果是多个该</span><span style="font-family:'Calibri';font-size:10.5pt;">word</span><span
        style="font-family:'宋体';font-size:10.5pt;">可以按</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”n”</span><span style="font-family:'宋体';font-size:10.5pt;">键显示下一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">另外你也可以不按</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”/”</span><span
        style="font-family:'宋体';font-size:10.5pt;">而是按</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”?”</span><span
        style="font-family:'宋体';font-size:10.5pt;">后边同样跟</span><span style="font-family:'Calibri';font-size:10.5pt;">word</span><span
        style="font-family:'宋体';font-size:10.5pt;">来搜索这个</span><span style="font-family:'Calibri';font-size:10.5pt;">word</span><span
        style="font-family:'宋体';font-size:10.5pt;">，唯一不同的是，</span><span style="font-family:'Calibri';font-size:10.5pt;">”/”</span><span
        style="font-family:'宋体';font-size:10.5pt;">是在当前行向下搜索，而</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”?”</span><span style="font-family:'宋体';font-size:10.5pt;">是在当前行向上搜索</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>head</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;">  head</span><span style="font-family:'宋体';font-size:10.5pt;">后直接跟文件名，则显示文件的前十行</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">如果加</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> –n </span><span style="font-family:'宋体';font-size:10.5pt;">选项则显示文件前</span><span
        style="font-family:'Calibri';font-size:10.5pt;">n</span><span
        style="font-family:'宋体';font-size:10.5pt;">行</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_78.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>tail </b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span
        style="font-family:'宋体';font-size:10.5pt;">和</span><span
        style="font-family:'Calibri';font-size:10.5pt;">head</span><span style="font-family:'宋体';font-size:10.5pt;">一样，后面直接跟文件名，则显示文件最后十行</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">如果加</span><span
        style="font-family:'Calibri';font-size:10.5pt;">-n </span><span style="font-family:'宋体';font-size:10.5pt;">选项则显示文件最后</span><span
        style="font-family:'Calibri';font-size:10.5pt;">n</span><span
        style="font-family:'宋体';font-size:10.5pt;">行</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_79.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">-f  </span><span
        style="font-family:'宋体';font-size:10.5pt;">动态显示文件的最后十行，如果文件是不断增加的，则用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">-f </span><span
        style="font-family:'宋体';font-size:10.5pt;">选项</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">如：</span><span style="font-family:'Calibri';font-size:10.5pt;">tail -f /var/log/messages</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">【</span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>文件的所属主以及所属组</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>】</b></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">目录或者文件，都会有一个所属主和所属组</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">所属主，即文件的拥有者，而所属组，即该文件所属主所在的一个组</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。Linux</span><span style="font-family:'宋体';font-size:10.5pt;">这样设置文件属性的目的是为了文件的安全</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">例如，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test</span><span style="font-family:'宋体';font-size:10.5pt;">文件的所属主是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">user0 </span><span
        style="font-family:'宋体';font-size:10.5pt;">而</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test1</span><span style="font-family:'宋体';font-size:10.5pt;">文件的所属主是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">user1</span><span
        style="font-family:'宋体';font-size:10.5pt;">，那么</span><span
        style="font-family:'Calibri';font-size:10.5pt;">user1</span><span style="font-family:'宋体';font-size:10.5pt;">是不能查看</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test</span><span style="font-family:'宋体';font-size:10.5pt;">文件的，相应的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">user0</span><span style="font-family:'宋体';font-size:10.5pt;">也不能查看</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test1</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">然后有这样一个应用，我想创建一个文件同时让</span><span
        style="font-family:'Calibri';font-size:10.5pt;">user0</span><span
        style="font-family:'宋体';font-size:10.5pt;">和</span><span
        style="font-family:'Calibri';font-size:10.5pt;">user1</span><span style="font-family:'宋体';font-size:10.5pt;">来查看怎么办呢？</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">这时</span><span
        style="font-family:'Calibri';font-size:10.5pt;">“</span><span
        style="font-family:'宋体';font-size:10.5pt;">所属组</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”</span><span
        style="font-family:'宋体';font-size:10.5pt;">就派上用场了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">即，创建一个群组</span><span
        style="font-family:'Calibri';font-size:10.5pt;">users</span><span
        style="font-family:'宋体';font-size:10.5pt;">，让</span><span
        style="font-family:'Calibri';font-size:10.5pt;">user0</span><span
        style="font-family:'宋体';font-size:10.5pt;">和</span><span
        style="font-family:'Calibri';font-size:10.5pt;">user1</span><span
        style="font-family:'宋体';font-size:10.5pt;">同属于</span><span
        style="font-family:'Calibri';font-size:10.5pt;">users</span><span style="font-family:'宋体';font-size:10.5pt;">组，然后建立一个文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test2</span><span style="font-family:'宋体';font-size:10.5pt;">，且其所属组为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">users</span><span
        style="font-family:'宋体';font-size:10.5pt;">，那么</span><span
        style="font-family:'Calibri';font-size:10.5pt;">user0</span><span
        style="font-family:'宋体';font-size:10.5pt;">和</span><span
        style="font-family:'Calibri';font-size:10.5pt;">user1</span><span style="font-family:'宋体';font-size:10.5pt;">都可以访问</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test2</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	Linux</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件属性不仅规定了所属主和所属组，还规定了所属主（</span><span
        style="font-family:'Calibri';font-size:10.5pt;">user</span><span
        style="font-family:'宋体';font-size:10.5pt;">）</span><span
        style="font-family:'Calibri';font-size:10.5pt;">、</span><span
        style="font-family:'宋体';font-size:10.5pt;">所属组</span><span style="font-family:'Calibri';font-size:10.5pt;">(group)</span><span
        style="font-family:'宋体';font-size:10.5pt;">以及其他用户（</span><span style="font-family:'Calibri';font-size:10.5pt;">others</span><span
        style="font-family:'宋体';font-size:10.5pt;">）对该文件的权限</span><span style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">你可以通过</span><span style="font-family:'Calibri';font-size:10.5pt;">ls  -l </span><span
        style="font-family:'宋体';font-size:10.5pt;">来查看这些属性</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_80.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>【linux</b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>文件属性</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>】</b></span></p>
<p style="text-align: justify;text-indent: 21pt;"><span style="font-family:'宋体';font-size:10.5pt;">上例中，用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">ls –l </span><span style="font-family:'宋体';font-size:10.5pt;">查看当前目录下的文件时，共显示了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">9</span><span style="font-family:'宋体';font-size:10.5pt;">列内容（用空格划分列），都代表了什么含义呢？</span>
</p>
<p style="text-align: justify;text-indent: 21pt;"><span style="font-family:'宋体';font-size:10.5pt;">第</span><span
        style="font-family:'Calibri';font-size:10.5pt;">1</span><span style="font-family:'宋体';font-size:10.5pt;">列，包含的东西有该文件类型和所属主</span><span
        style="font-family:'Calibri';font-size:10.5pt;">、</span><span style="font-family:'宋体';font-size:10.5pt;">所属组以及其他用户对该文件的权限</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">第一列共</span><span
        style="font-family:'Calibri';font-size:10.5pt;">10</span><span
        style="font-family:'宋体';font-size:10.5pt;">位</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">其中第一位用来描述该文件的类型</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">上例中，我们看到的类型有</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”d”, “-“ </span><span
        style="font-family:'宋体';font-size:10.5pt;">，其实除了这两种外还有</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”l”, “b”, “c”,”s”</span><span
        style="font-family:'宋体';font-size:10.5pt;">等</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">d </span><span
        style="font-family:'宋体';font-size:10.5pt;">表示该文件为目录；</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">- </span><span
        style="font-family:'宋体';font-size:10.5pt;">表示该文件为普通文件；</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">l </span><span
        style="font-family:'宋体';font-size:10.5pt;">表示该文件为连接文件（</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux file</span><span
        style="font-family:'宋体';font-size:10.5pt;">），上边提到的软连接即为该类型；</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_81.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">b </span><span
        style="font-family:'宋体';font-size:10.5pt;">表示该文件为块设备文件，比如磁盘分区</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_82.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">c </span><span
        style="font-family:'宋体';font-size:10.5pt;">表示该文件为串行端口设备，例如键盘</span><span
        style="font-family:'Calibri';font-size:10.5pt;">、</span><span
        style="font-family:'宋体';font-size:10.5pt;">鼠标</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">s </span><span
        style="font-family:'宋体';font-size:10.5pt;">表示该文件为套接字文件（</span><span
        style="font-family:'Calibri';font-size:10.5pt;">socket</span><span style="font-family:'宋体';font-size:10.5pt;">），用于进程间通信</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">后边的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">9</span><span style="font-family:'宋体';font-size:10.5pt;">位，每三个为一组</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">均为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rwx </span><span style="font-family:'宋体';font-size:10.5pt;">三个参数的组合</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">其中</span><span
        style="font-family:'Calibri';font-size:10.5pt;">r </span><span
        style="font-family:'宋体';font-size:10.5pt;">代表可读，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">w</span><span
        style="font-family:'宋体';font-size:10.5pt;">代表可写，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">x</span><span
        style="font-family:'宋体';font-size:10.5pt;">代表可执行</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">前三位为所属主（</span><span
        style="font-family:'Calibri';font-size:10.5pt;">user</span><span style="font-family:'宋体';font-size:10.5pt;">）的权限，中间三位为所属组（</span><span
        style="font-family:'Calibri';font-size:10.5pt;">group</span><span style="font-family:'宋体';font-size:10.5pt;">）的权限，最后三位为其他非本群组（</span><span
        style="font-family:'Calibri';font-size:10.5pt;">others</span><span style="font-family:'宋体';font-size:10.5pt;">）的权限</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">下面拿一个具体的例子来述说一下</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">一个文件的属性为</span><span style="font-family:'Calibri';font-size:10.5pt;">-rwxr-xr-- </span><span
        style="font-family:'宋体';font-size:10.5pt;">，它代表的意思是，该文件为普通文件，文件拥有者可读可写可执行，文件所属组对其可读不可写可执行，其他用户对其只可读</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">对于一个目录来讲，打开这个目录即为执行这个目录，所以任何一个目录必须要有</span><span
        style="font-family:'Calibri';font-size:10.5pt;">x</span><span style="font-family:'宋体';font-size:10.5pt;">权限才能打开并查看该目录</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">例如一个目录的属性为</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> drwxr--r-- </span><span
        style="font-family:'宋体';font-size:10.5pt;">其所属主为</span><span style="font-family:'Calibri';font-size:10.5pt;">root</span><span
        style="font-family:'宋体';font-size:10.5pt;">，那么除了</span><span style="font-family:'Calibri';font-size:10.5pt;">root</span><span
        style="font-family:'宋体';font-size:10.5pt;">外的其他用户是不能打开这个目录的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">第</span><span
        style="font-family:'Calibri';font-size:10.5pt;">2</span><span style="font-family:'宋体';font-size:10.5pt;">列，表示为连接占用的节点（</span><span
        style="font-family:'Calibri';font-size:10.5pt;">inode</span><span style="font-family:'宋体';font-size:10.5pt;">），若为目录时，通常与该目录地下还有多少目录有关系，关于连接（</span><span
        style="font-family:'Calibri';font-size:10.5pt;">link</span><span style="font-family:'宋体';font-size:10.5pt;">）在以后章节详细介绍</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">第</span><span
        style="font-family:'Calibri';font-size:10.5pt;">3</span><span style="font-family:'宋体';font-size:10.5pt;">列，表示该文件的所属主</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">第</span><span
        style="font-family:'Calibri';font-size:10.5pt;">4</span><span style="font-family:'宋体';font-size:10.5pt;">列，表示该文件的所属组</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">第</span><span
        style="font-family:'Calibri';font-size:10.5pt;">5</span><span style="font-family:'宋体';font-size:10.5pt;">列，表示该文件的大小</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">第</span><span
        style="font-family:'Calibri';font-size:10.5pt;">6</span><span
        style="font-family:'宋体';font-size:10.5pt;">列</span><span
        style="font-family:'Calibri';font-size:10.5pt;">、</span><span
        style="font-family:'宋体';font-size:10.5pt;">第</span><span
        style="font-family:'Calibri';font-size:10.5pt;">7</span><span
        style="font-family:'宋体';font-size:10.5pt;">列和第</span><span
        style="font-family:'Calibri';font-size:10.5pt;">8</span><span style="font-family:'宋体';font-size:10.5pt;">列为该文件的创建日期或者最近的修改日期，分别为月份日期以及时间</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">第</span><span
        style="font-family:'Calibri';font-size:10.5pt;">9</span><span
        style="font-family:'宋体';font-size:10.5pt;">列，文件名</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">如果前面有一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">. </span><span style="font-family:'宋体';font-size:10.5pt;">则表示该文件为隐藏文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">【</span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>更改文件的权限</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>】</b></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">更改文件的权限，也就是更改所属主</span><span
        style="font-family:'Calibri';font-size:10.5pt;">、</span><span style="font-family:'宋体';font-size:10.5pt;">所属组以及他们对应的读写执行权限</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">1</span><span
        style="font-family:'宋体';font-size:10.5pt;">）</span><span style="font-family:'宋体';font-size:10.5pt;"><b>更改所属组</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b> chgrp</b></span></p>
<p><span style="font-family:'宋体';font-size:10.5pt;">语法：</span><span style="font-family:'Calibri';font-size:10.5pt;">chgrp  [</span><span
        style="font-family:'宋体';font-size:10.5pt;">组名</span><span
        style="font-family:'Calibri';font-size:10.5pt;">]  [</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件名</span><span
        style="font-family:'Calibri';font-size:10.5pt;">] </span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">&nbsp;</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_83.png"></span></p>
<p><span style="font-family:'宋体';font-size:10.5pt;">这里用到了</span><span style="font-family:'Calibri';font-size:10.5pt;">groupadd </span><span
        style="font-family:'宋体';font-size:10.5pt;">命令，其含义即增加一个用户组</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">该命令在以后章节中做详细介绍，你只要知道它是用来增加用户组的即可</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">2</span><span
        style="font-family:'宋体';font-size:10.5pt;">）</span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>更改文件的所属主</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b> chown </b></span></p>
<p><span style="font-family:'宋体';font-size:10.5pt;">语法：</span><span style="font-family:'Calibri';font-size:10.5pt;">chown [ -R ] </span><span
        style="font-family:'宋体';font-size:10.5pt;">账户名</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span
        style="font-family:'宋体';font-size:10.5pt;">文件名</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">	  chown [ -R ] </span><span
        style="font-family:'宋体';font-size:10.5pt;">账户名：组名</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span
        style="font-family:'宋体';font-size:10.5pt;">文件名</span></p>
<p><span style="font-family:'宋体';font-size:10.5pt;">这里的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">-R</span><span style="font-family:'宋体';font-size:10.5pt;">选项只作用于目录，作用是级联更改，即不仅更改当前目录，连目录里的目录或者文件全部更改</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_84.png"></span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">useradd </span><span
        style="font-family:'宋体';font-size:10.5pt;">是增加一个账户，以后会详细介绍</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">上例中，首先建立一个目录</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test</span><span
        style="font-family:'宋体';font-size:10.5pt;">，然后在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test</span><span style="font-family:'宋体';font-size:10.5pt;">目录下创建一个普通文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test2</span><span style="font-family:'宋体';font-size:10.5pt;">，因为是以</span><span
        style="font-family:'Calibri';font-size:10.5pt;">root</span><span style="font-family:'宋体';font-size:10.5pt;">的身份创建的目录和文件，所以所属主以及所属组都是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">root。chown user1 test  </span><span
        style="font-family:'宋体';font-size:10.5pt;">这使</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test</span><span style="font-family:'宋体';font-size:10.5pt;">的目录所属主由</span><span
        style="font-family:'Calibri';font-size:10.5pt;">root</span><span
        style="font-family:'宋体';font-size:10.5pt;">变为了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">user1 </span><span style="font-family:'宋体';font-size:10.5pt;">，然后</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test</span><span
        style="font-family:'宋体';font-size:10.5pt;">目录下的</span><span style="font-family:'Calibri';font-size:10.5pt;">test2</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件所属主以及所属组还是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">root。</span><span
        style="font-family:'宋体';font-size:10.5pt;">接着</span><span style="font-family:'Calibri';font-size:10.5pt;"> chown –R user1:testgroup test  </span><span
        style="font-family:'宋体';font-size:10.5pt;">这样把</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test</span><span
        style="font-family:'宋体';font-size:10.5pt;">连同</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test</span><span
        style="font-family:'宋体';font-size:10.5pt;">目录下的</span><span style="font-family:'Calibri';font-size:10.5pt;">test2 </span><span
        style="font-family:'宋体';font-size:10.5pt;">的所属主以及所属组都改变了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">3</span><span
        style="font-family:'宋体';font-size:10.5pt;">）</span><span style="font-family:'宋体';font-size:10.5pt;"><b>改变用户对文件的读写执行权限</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b> chmod</b></span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">中为了方便更改这些权限，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">使用数字去代替</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rwx </span><span style="font-family:'宋体';font-size:10.5pt;">，具体规则为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">r: 4  w:2  x:1  -:0 </span><span
        style="font-family:'宋体';font-size:10.5pt;">举个例子，</span><span style="font-family:'Calibri';font-size:10.5pt;">-rwxrwx---</span><span
        style="font-family:'宋体';font-size:10.5pt;">用数字表示就是</span><span style="font-family:'Calibri';font-size:10.5pt;"> 770</span><span
        style="font-family:'宋体';font-size:10.5pt;">，具体是这样来的：</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">rwx = 4+2+1=7;  rwx= 4+2+1=7; --- = 0+0+0=0</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">chmod </span><span style="font-family:'宋体';font-size:10.5pt;">语法：</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> chmod [-R] xyz </span><span
        style="font-family:'宋体';font-size:10.5pt;">文件名</span><span
        style="font-family:'Calibri';font-size:10.5pt;">  </span><span
        style="font-family:'宋体';font-size:10.5pt;">（这里的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">xyz</span><span style="font-family:'宋体';font-size:10.5pt;">，表示数字）</span>
</p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">-R </span><span style="font-family:'宋体';font-size:10.5pt;">选项作用同</span><span
        style="font-family:'Calibri';font-size:10.5pt;">chown</span><span style="font-family:'宋体';font-size:10.5pt;">，级联更改</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p><span style="font-family:'宋体';font-size:10.5pt;">值得提一下的是，在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">系统中，默认一个目录的权限为</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> 755</span><span style="font-family:'宋体';font-size:10.5pt;">，而一个文件的默认权限为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">644.</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_85.png"></span></p>
<p><span style="font-family:'宋体';font-size:10.5pt;">如果你创建了一个目录，而该目录不想让其他人看到内容，则只需设置成</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> rwxr----- (740) </span><span
        style="font-family:'宋体';font-size:10.5pt;">即可</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">	chmod </span><span
        style="font-family:'宋体';font-size:10.5pt;">还支持使用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rwx</span><span style="font-family:'宋体';font-size:10.5pt;">的方式来设置权限</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">！从之前的介绍中我们可以发现，基本上就九个属性分别是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">(1)user (2)group (3)others </span><span
        style="font-family:'宋体';font-size:10.5pt;">三群啦！那么我们就可以藉由</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> u, g, o </span><span
        style="font-family:'宋体';font-size:10.5pt;">来代表三群的属性！此外，</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> a </span><span
        style="font-family:'宋体';font-size:10.5pt;">则代表</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> all </span><span style="font-family:'宋体';font-size:10.5pt;">亦即全部的三群！那么读写的属性就可以写成了</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> r, w, x</span><span style="font-family:'宋体';font-size:10.5pt;">！也就是可以使用底下的方式来看：</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_86.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">现在我想把一个文件设置成这样的权限</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> rwxr-xr-x (755)</span><span
        style="font-family:'宋体';font-size:10.5pt;">，使用这种方式改变权限的命令为</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_87.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">另外还可以针对</span><span
        style="font-family:'Calibri';font-size:10.5pt;">u, g, o, a</span><span
        style="font-family:'宋体';font-size:10.5pt;">增加或者减少某个权限（读，写，执行），例如</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_88.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">另外linux下还有两个比较特殊的权限s和t，请点击<a
        href="javascript:if(confirm('http://www.92csz.com/thread-617-1-1.html  \n\n���ļ��޷��� Teleport Ultra ����, ��Ϊ ����һ�����·���ⲿ������Ϊ������ʼ��ַ�ĵ�ַ��  \n\n�����ڷ������ϴ���?'))window.location='http://www.92csz.com/thread-617-1-1.html'">linux下文件的特殊权限s和t</a></span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>umask</b></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">上边也提到了默认情况下，目录权限值为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">766</span><span style="font-family:'宋体';font-size:10.5pt;">，普通文件权限值为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">644。</span><span style="font-family:'宋体';font-size:10.5pt;">那么这个值是由谁规定呢？追究其原因就涉及到了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">umask。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">umask</span><span
        style="font-family:'宋体';font-size:10.5pt;">语法：</span><span style="font-family:'Calibri';font-size:10.5pt;"> umask  xxx  </span><span
        style="font-family:'宋体';font-size:10.5pt;">（这里的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">xxx</span><span style="font-family:'宋体';font-size:10.5pt;">代表三个数字）</span>
</p>
<p style="text-align: justify;text-indent: 21pt;"><span style="font-family:'宋体';font-size:10.5pt;">查看</span><span
        style="font-family:'Calibri';font-size:10.5pt;">umask</span><span style="font-family:'宋体';font-size:10.5pt;">值只要输入</span><span
        style="font-family:'Calibri';font-size:10.5pt;">umask</span><span style="font-family:'宋体';font-size:10.5pt;">然后回车</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。 umask</span><span style="font-family:'宋体';font-size:10.5pt;">预设是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">0022</span><span style="font-family:'宋体';font-size:10.5pt;">，其代表什么含义？先看一下下面的规则：</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">1</span><span
        style="font-family:'宋体';font-size:10.5pt;">）若用户建立为普通文件，则预设</span><span
        style="font-family:'Calibri';font-size:10.5pt;">“</span><span
        style="font-family:'宋体';font-size:10.5pt;">没有可执行权限</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”</span><span
        style="font-family:'宋体';font-size:10.5pt;">，只有</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rw</span><span
        style="font-family:'宋体';font-size:10.5pt;">两个权限</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">最大为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">666</span><span
        style="font-family:'宋体';font-size:10.5pt;">（</span><span style="font-family:'Calibri';font-size:10.5pt;">-rw-rw-rw-</span><span
        style="font-family:'宋体';font-size:10.5pt;">）</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">2</span><span
        style="font-family:'宋体';font-size:10.5pt;">）若用户建立为目录，则预设所有权限均开放，即</span><span
        style="font-family:'Calibri';font-size:10.5pt;">777</span><span
        style="font-family:'宋体';font-size:10.5pt;">（</span><span style="font-family:'Calibri';font-size:10.5pt;">drwxrwxrwx</span><span
        style="font-family:'宋体';font-size:10.5pt;">）</span></p>
<p style="text-align: justify;text-indent: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">umask</span><span style="font-family:'宋体';font-size:10.5pt;">数值代表的含义为，上边两条规则中的</span><span
        style="font-family:'宋体';font-size:10.5pt; color:#FF0000;">默认值（文件为</span><span
        style="font-family:'Calibri';font-size:10.5pt; color:#FF0000;">666</span><span
        style="font-family:'宋体';font-size:10.5pt; color:#FF0000;">，目录为</span><span
        style="font-family:'Calibri';font-size:10.5pt; color:#FF0000;">777</span><span
        style="font-family:'宋体';font-size:10.5pt; color:#FF0000;">）需要减掉的权限</span><span
        style="font-family:'Calibri';font-size:10.5pt; color:#FF0000;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">所以目录的权限为</span><span style="font-family:'Calibri';font-size:10.5pt;">(rwxrwxrwx) – (----w--w-) = (rwxr-xr-x)</span><span
        style="font-family:'宋体';font-size:10.5pt;">，普通文件的权限为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">(rw-rw-rw-) – (----w--w-) = (rw-r--r--)。umask</span><span
        style="font-family:'宋体';font-size:10.5pt;">的值是可以自定义的，比如设定</span><span
        style="font-family:'Calibri';font-size:10.5pt;">umask </span><span
        style="font-family:'宋体';font-size:10.5pt;">为</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> 002</span><span style="font-family:'宋体';font-size:10.5pt;">，你再创建目录或者文件时，默认权限分别为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">(rwxrwxrwx) – (-------w-) = (rwxrwxr-x)</span><span
        style="font-family:'宋体';font-size:10.5pt;">和</span><span style="font-family:'Calibri';font-size:10.5pt;">(rw-rw-rw-) – (-------w-) = (rw-rw-r--)。</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_89.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	umask </span><span
        style="font-family:'宋体';font-size:10.5pt;">可以在</span><span style="font-family:'Calibri';font-size:10.5pt;">/etc/bashrc</span><span
        style="font-family:'宋体';font-size:10.5pt;">里面更改，预设情况下，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">root</span><span
        style="font-family:'宋体';font-size:10.5pt;">的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">umask</span><span
        style="font-family:'宋体';font-size:10.5pt;">为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">022</span><span style="font-family:'宋体';font-size:10.5pt;">，而一般使用者则为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">002</span><span style="font-family:'宋体';font-size:10.5pt;">，因为可写的权限非常重要，因此预设会去掉写权限</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>chattr </b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>修改文件的特殊属性</b></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">语法：</span><span style="font-family:'Calibri';font-size:10.5pt;"> chattr  [+-=][ASaci [</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件或者目录名</span><span
        style="font-family:'Calibri';font-size:10.5pt;">]</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	+-= </span><span
        style="font-family:'宋体';font-size:10.5pt;">：分别为增加</span><span
        style="font-family:'Calibri';font-size:10.5pt;">、</span><span
        style="font-family:'宋体';font-size:10.5pt;">减少</span><span
        style="font-family:'Calibri';font-size:10.5pt;">、</span><span
        style="font-family:'宋体';font-size:10.5pt;">设定</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	A</span><span
        style="font-family:'宋体';font-size:10.5pt;">：增加该属性后，文件或目录的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">atime</span><span style="font-family:'宋体';font-size:10.5pt;">将不可被修改；</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	S</span><span
        style="font-family:'宋体';font-size:10.5pt;">：增加该属性后，会将数据同步写入磁盘中；</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	a</span><span
        style="font-family:'宋体';font-size:10.5pt;">：增加该属性后，只能追加不能删除，非</span><span
        style="font-family:'Calibri';font-size:10.5pt;">root</span><span style="font-family:'宋体';font-size:10.5pt;">用户不能设定该属性；</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	c</span><span
        style="font-family:'宋体';font-size:10.5pt;">：自动压缩该文件，读取时会自动解压；</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	i</span><span
        style="font-family:'宋体';font-size:10.5pt;">：增加后，使文件不能被删除</span><span
        style="font-family:'Calibri';font-size:10.5pt;">、</span><span
        style="font-family:'宋体';font-size:10.5pt;">重命名</span><span
        style="font-family:'Calibri';font-size:10.5pt;">、</span><span
        style="font-family:'宋体';font-size:10.5pt;">设定连接</span><span
        style="font-family:'Calibri';font-size:10.5pt;">、</span><span
        style="font-family:'宋体';font-size:10.5pt;">写入</span><span
        style="font-family:'Calibri';font-size:10.5pt;">、</span><span
        style="font-family:'宋体';font-size:10.5pt;">新增数据；</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_90.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">增加</span><span
        style="font-family:'Calibri';font-size:10.5pt;">i</span><span style="font-family:'宋体';font-size:10.5pt;">属性后不能在该目录中建立文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_91.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">增加</span><span
        style="font-family:'Calibri';font-size:10.5pt;">a</span><span style="font-family:'宋体';font-size:10.5pt;">属性后，只能追加不能删除</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>lsattr </b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>列出文件</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>/</b></span><span style="font-family:'宋体';font-size:10.5pt;"><b>目录的特殊属性</b></span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">语法：</span><span style="font-family:'Calibri';font-size:10.5pt;"> lsattr  [-aR] [</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/</span><span
        style="font-family:'宋体';font-size:10.5pt;">目录名</span><span
        style="font-family:'Calibri';font-size:10.5pt;">]</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-a</span><span
        style="font-family:'宋体';font-size:10.5pt;">：类似与</span><span
        style="font-family:'Calibri';font-size:10.5pt;">ls </span><span
        style="font-family:'宋体';font-size:10.5pt;">的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">-a </span><span style="font-family:'宋体';font-size:10.5pt;">选项，即连同隐藏文件一同列出；</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-R</span><span
        style="font-family:'宋体';font-size:10.5pt;">：连同子目录的数据一同列出</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_92.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">在上例中，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test4</span><span
        style="font-family:'宋体';font-size:10.5pt;">是在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test3</span><span style="font-family:'宋体';font-size:10.5pt;">目录增加</span><span
        style="font-family:'Calibri';font-size:10.5pt;">a</span><span style="font-family:'宋体';font-size:10.5pt;">属性后建立的，所以</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test4</span><span
        style="font-family:'宋体';font-size:10.5pt;">也有</span><span
        style="font-family:'Calibri';font-size:10.5pt;">a</span><span style="font-family:'宋体';font-size:10.5pt;">属性，通过这个例子可以看出，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">chattr </span><span style="font-family:'宋体';font-size:10.5pt;">的属性是级联生效的，不仅对当前目录生效而且会对目录下的文件同样生效</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">【</span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>在</b></span><span style="font-family:'Calibri';font-size:10.5pt;"><b>linux</b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>下搜索一个文件</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;">】</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">windows</span><span style="font-family:'宋体';font-size:10.5pt;">下有一个搜索工具，可以让我们很快的找到一个文件，这是很有用的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">然而在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">下搜索功能更加强大</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>which</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;">  </span><span style="font-family:'宋体';font-size:10.5pt;">用来查找可执行文件的绝对路径</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">在前面章节中已经多次用到该命令，需要注意的一点是，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">which</span><span style="font-family:'宋体';font-size:10.5pt;">只能用来查找</span><span
        style="font-family:'Calibri';font-size:10.5pt;">PATH</span><span style="font-family:'宋体';font-size:10.5pt;">环境变量中出现的路径下的可执行文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">这个命令用的也是蛮多的，有时候我们不知道某个命令的绝对路径，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">which</span><span style="font-family:'宋体';font-size:10.5pt;">一下很容易就知道了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_93.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">当查找的文件在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">PATH</span><span style="font-family:'宋体';font-size:10.5pt;">变量中并没有时，就会报错</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>whereis </b></span><span
        style="font-family:'宋体';font-size:10.5pt;">通过预先生成的一个文件列表库去查找跟给出的文件名相关的文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">语法：</span><span style="font-family:'Calibri';font-size:10.5pt;"> whereis [-bmsu]  [</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件名称</span><span
        style="font-family:'Calibri';font-size:10.5pt;">]</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-b</span><span
        style="font-family:'宋体';font-size:10.5pt;">：只找</span><span style="font-family:'Calibri';font-size:10.5pt;">binary </span><span
        style="font-family:'宋体';font-size:10.5pt;">文件</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-m</span><span
        style="font-family:'宋体';font-size:10.5pt;">：只找在说明文件</span><span style="font-family:'Calibri';font-size:10.5pt;">manual</span><span
        style="font-family:'宋体';font-size:10.5pt;">路径下的文件</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-s</span><span
        style="font-family:'宋体';font-size:10.5pt;">：只找</span><span style="font-family:'Calibri';font-size:10.5pt;">source</span><span
        style="font-family:'宋体';font-size:10.5pt;">来源文件</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-u</span><span
        style="font-family:'宋体';font-size:10.5pt;">：没有说明档的文件</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_94.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">说明：</span><span
        style="font-family:'Calibri';font-size:10.5pt;">whereis </span><span style="font-family:'宋体';font-size:10.5pt;">笔者几乎很少用到，如果你感兴趣请深入研究</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>locate</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;">  </span><span
        style="font-family:'宋体';font-size:10.5pt;">类似于</span><span style="font-family:'Calibri';font-size:10.5pt;">whereis</span><span
        style="font-family:'宋体';font-size:10.5pt;">，也是通过查找预先生成的文件列表库来告诉用户要查找的文件在哪里</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">后边直接跟文件名</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">如果你的</span><span style="font-family:'Calibri';font-size:10.5pt;">linux</span><span
        style="font-family:'宋体';font-size:10.5pt;">没有这个命令，请安装软件包</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> mlocate </span><span
        style="font-family:'宋体';font-size:10.5pt;">，这个软件包在你的系统安装盘里，后缀名是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">RPM</span><span style="font-family:'宋体';font-size:10.5pt;">，随后介绍的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">find</span><span style="font-family:'宋体';font-size:10.5pt;">命令会告诉你如何查找这个包</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">如果你装的</span><span style="font-family:'Calibri';font-size:10.5pt;">CentOS</span><span
        style="font-family:'宋体';font-size:10.5pt;">你可以使用这个命令来安装</span><span
        style="font-family:'Calibri';font-size:10.5pt;">  yum install –y  mlocate 。 </span><span
        style="font-family:'宋体';font-size:10.5pt;">前提是你的</span><span style="font-family:'Calibri';font-size:10.5pt;">CentOS</span><span
        style="font-family:'宋体';font-size:10.5pt;">能连互联网</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">至于</span><span
        style="font-family:'Calibri';font-size:10.5pt;">yum</span><span style="font-family:'宋体';font-size:10.5pt;">这个命令如何使用，到后续章节你自然会明白</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">如果你刚装上这个命令，初次使用会报错</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_95.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">这是因为系统还没有生成那个文件列表库</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">你可以使用</span><span style="font-family:'Calibri';font-size:10.5pt;">updatedb </span><span
        style="font-family:'宋体';font-size:10.5pt;">命令立即生成（更新）这个库</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">如果你的服务器上正跑着重要的业务，那么你最好不要去运行这个命令，因为一旦运行，服务器的压力会变大</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">这个数据库默认情况下每周更新一次</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">所以你用</span><span style="font-family:'Calibri';font-size:10.5pt;">locate</span><span
        style="font-family:'宋体';font-size:10.5pt;">命令去搜索一个文件，正好是在两次更新时间段内，那你肯定是得不到结果的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">你可以到</span><span style="font-family:'Calibri';font-size:10.5pt;">/etc/updated.conf </span><span
        style="font-family:'宋体';font-size:10.5pt;">去配置这个数据库生成（更新）的规则</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。locate</span><span style="font-family:'宋体';font-size:10.5pt;">命令笔者用的也并不多，所以你只要明白有这么一个东西即可</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">你用到时再去深究其用法吧</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>find </b></span><span
        style="font-family:'宋体';font-size:10.5pt;">这个搜索工具是笔者用的最多的一个，所以请你务必要熟悉它</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">语法：</span><span style="font-family:'Calibri';font-size:10.5pt;"> find  [</span><span
        style="font-family:'宋体';font-size:10.5pt;">路径</span><span
        style="font-family:'Calibri';font-size:10.5pt;">] [</span><span
        style="font-family:'宋体';font-size:10.5pt;">参数</span><span
        style="font-family:'Calibri';font-size:10.5pt;">]  </span><span style="font-family:'宋体';font-size:10.5pt;">下面介绍几个笔者经常用的参数</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-atime  +n </span><span
        style="font-family:'宋体';font-size:10.5pt;">：访问或执行时间大于</span><span
        style="font-family:'Calibri';font-size:10.5pt;">n</span><span
        style="font-family:'宋体';font-size:10.5pt;">天的文件</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-ctime  +n </span><span
        style="font-family:'宋体';font-size:10.5pt;">：写入</span><span
        style="font-family:'Calibri';font-size:10.5pt;">、</span><span
        style="font-family:'宋体';font-size:10.5pt;">更改</span><span
        style="font-family:'Calibri';font-size:10.5pt;">inode</span><span style="font-family:'宋体';font-size:10.5pt;">属性（例如更改所有者</span><span
        style="font-family:'Calibri';font-size:10.5pt;">、</span><span style="font-family:'宋体';font-size:10.5pt;">权限或者连接）时间大于</span><span
        style="font-family:'Calibri';font-size:10.5pt;">n</span><span
        style="font-family:'宋体';font-size:10.5pt;">天的文件</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-mtime  +n </span><span
        style="font-family:'宋体';font-size:10.5pt;">：写入时间大于</span><span
        style="font-family:'Calibri';font-size:10.5pt;">n</span><span
        style="font-family:'宋体';font-size:10.5pt;">天的文件</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">看到这里，你对这三个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">time</span><span style="font-family:'宋体';font-size:10.5pt;">是不是有些晕了，那笔者就先给你介绍一下这三个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">time</span><span
        style="font-family:'宋体';font-size:10.5pt;">属性</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件的</span><span style="font-family:'Calibri';font-size:10.5pt;"> Access time</span><span
        style="font-family:'宋体';font-size:10.5pt;">，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">atime </span><span style="font-family:'宋体';font-size:10.5pt;">是在读取文件或者执行文件时更改的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件的</span><span style="font-family:'Calibri';font-size:10.5pt;"> Modified time</span><span
        style="font-family:'宋体';font-size:10.5pt;">，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">mtime </span><span style="font-family:'宋体';font-size:10.5pt;">是在写入文件时随文件内容的更改而更改的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件的</span><span style="font-family:'Calibri';font-size:10.5pt;"> Create time</span><span
        style="font-family:'宋体';font-size:10.5pt;">，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">ctime </span><span style="font-family:'宋体';font-size:10.5pt;">是在写入文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">、</span><span
        style="font-family:'宋体';font-size:10.5pt;">更改所有者</span><span
        style="font-family:'Calibri';font-size:10.5pt;">、</span><span
        style="font-family:'宋体';font-size:10.5pt;">权限</span><span
        style="font-family:'宋体';font-size:10.5pt;">或链接</span><span
        style="font-family:'宋体';font-size:10.5pt;">设置</span><span
        style="font-family:'宋体';font-size:10.5pt;">时随</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> Inode </span><span style="font-family:'宋体';font-size:10.5pt;">的内容更改而更改的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。 </span><span style="font-family:'宋体';font-size:10.5pt;">因此，更改文件的内容即会更改</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> mtime </span><span
        style="font-family:'宋体';font-size:10.5pt;">和</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> ctime</span><span style="font-family:'宋体';font-size:10.5pt;">，但是文件的</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> ctime </span><span style="font-family:'宋体';font-size:10.5pt;">可能会在</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> mtime </span><span style="font-family:'宋体';font-size:10.5pt;">未发生任何变化时更改，例如，更改了文件的权限，但是文件内容没有变化</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。 </span><span style="font-family:'宋体';font-size:10.5pt;">如何获得一个文件的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">atime mtime </span><span
        style="font-family:'宋体';font-size:10.5pt;">以及</span><span
        style="font-family:'Calibri';font-size:10.5pt;">ctime </span><span
        style="font-family:'宋体';font-size:10.5pt;">？</span></p>
<p style="text-align: justify;text-indent: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">ls -l </span><span style="font-family:'宋体';font-size:10.5pt;">命令可用来列出文件的</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> atime、ctime </span><span
        style="font-family:'宋体';font-size:10.5pt;">和</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> mtime。</span></p>
<p style="text-align: justify;text-indent: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;">ls -lc filename&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</span><span
        style="font-family:'宋体';font-size:10.5pt;">列出文件的</span><span style="font-family:'Calibri';font-size:10.5pt;"> ctime</span>
</p>
<p style="text-align: justify;text-indent: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;">ls -lu filename&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</span><span
        style="font-family:'宋体';font-size:10.5pt;">列出文件的</span><span style="font-family:'Calibri';font-size:10.5pt;"> atime</span>
</p>
<p style="text-align: justify;text-indent: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;">ls -l filename&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; </span><span
        style="font-family:'宋体';font-size:10.5pt;">列出文件的</span><span style="font-family:'Calibri';font-size:10.5pt;"> mtime &nbsp; &nbsp;</span>
</p>
<p style="text-align: justify;text-indent: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">atime</span><span style="font-family:'宋体';font-size:10.5pt;">不一定在</span><span
        style="font-family:'宋体';font-size:10.5pt;">访问</span><span style="font-family:'宋体';font-size:10.5pt;">文件之后被修改，因为：使用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">ext3</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件</span><span
        style="font-family:'宋体';font-size:10.5pt;">系统</span><span
        style="font-family:'宋体';font-size:10.5pt;">的时候，如果在</span><span style="font-family:'Calibri';font-size:10.5pt;">mount</span><span
        style="font-family:'宋体';font-size:10.5pt;">的时候使用了</span><span style="font-family:'Calibri';font-size:10.5pt;">noatime</span><span
        style="font-family:'宋体';font-size:10.5pt;">参数那么就不会更新</span><span
        style="font-family:'Calibri';font-size:10.5pt;">atime</span><span
        style="font-family:'宋体';font-size:10.5pt;">的信息</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">而这是加了</span><span style="font-family:'Calibri';font-size:10.5pt;"> noatime </span><span
        style="font-family:'宋体';font-size:10.5pt;">取消了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">, </span><span style="font-family:'宋体';font-size:10.5pt;">不代表真实情況</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">反正</span><span
        style="font-family:'Calibri';font-size:10.5pt;">, </span><span
        style="font-family:'宋体';font-size:10.5pt;">這三個</span><span style="font-family:'Calibri';font-size:10.5pt;"> time stamp </span><span
        style="font-family:'宋体';font-size:10.5pt;">都放在</span><span style="font-family:'Calibri';font-size:10.5pt;"> inode </span><span
        style="font-family:'宋体';font-size:10.5pt;">中</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">若</span><span style="font-family:'Calibri';font-size:10.5pt;"> mtime, atime </span><span
        style="font-family:'宋体';font-size:10.5pt;">修改</span><span
        style="font-family:'Calibri';font-size:10.5pt;">inode </span><span style="font-family:'宋体';font-size:10.5pt;">就一定會改</span><span
        style="font-family:'Calibri';font-size:10.5pt;">, </span><span
        style="font-family:'宋体';font-size:10.5pt;">既然</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> inode </span><span style="font-family:'宋体';font-size:10.5pt;">改了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">, </span><span
        style="font-family:'宋体';font-size:10.5pt;">那</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> ctime </span><span style="font-family:'宋体';font-size:10.5pt;">也就跟著要改了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;text-indent: 21pt;"><span style="font-family:'宋体';font-size:10.5pt;">继续讲</span><span
        style="font-family:'Calibri';font-size:10.5pt;">find</span><span style="font-family:'宋体';font-size:10.5pt;">常用的参数</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;text-indent: 21pt;"><span
        style="font-family:'Calibri';font-size:10.5pt;">-name filename  </span><span
        style="font-family:'宋体';font-size:10.5pt;">直接查找该文件名的文件，这个使用最多了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_96.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	-type  type </span><span
        style="font-family:'宋体';font-size:10.5pt;">：通过文件类型查找</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">文件类型在前面部分已经简单介绍过，相信你已经大体上了解了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。type </span><span style="font-family:'宋体';font-size:10.5pt;">包含了</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> f, b, c, d, l, s </span><span
        style="font-family:'宋体';font-size:10.5pt;">等等</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">后续的内容还会介绍文件类型的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_97.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">【</span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>linux</b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>的文件系统</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;">】</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">搞计算机的应该都知道</span><span
        style="font-family:'Calibri';font-size:10.5pt;">windows</span><span style="font-family:'宋体';font-size:10.5pt;">的系统格式化硬盘时会指定格式，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">fat </span><span
        style="font-family:'宋体';font-size:10.5pt;">或者</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> ntfs。</span><span
        style="font-family:'宋体';font-size:10.5pt;">而</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">的文件系统格式为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Ext2</span><span
        style="font-family:'宋体';font-size:10.5pt;">，或者</span><span style="font-family:'Calibri';font-size:10.5pt;">Ext3 。</span><span
        style="font-family:'宋体';font-size:10.5pt;">早期的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span
        style="font-family:'宋体';font-size:10.5pt;">使用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Ext2</span><span style="font-family:'宋体';font-size:10.5pt;">格式，目前的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">都使用了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Ext3。 Ext2</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件系统虽然是高效稳定的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">但是，随着</span><span style="font-family:'Calibri';font-size:10.5pt;">Linux</span><span
        style="font-family:'宋体';font-size:10.5pt;">系统在关键业务中的应用，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Linux</span><span style="font-family:'宋体';font-size:10.5pt;">文件系统的弱点也渐渐显露出来了，因为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Ext2</span><span style="font-family:'宋体';font-size:10.5pt;">文件系统是非日志文件系统</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">这在关键行业的应用是一个致命的弱点</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。Ext3</span><span style="font-family:'宋体';font-size:10.5pt;">文件系统是直接从</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Ext2</span><span style="font-family:'宋体';font-size:10.5pt;">文件系统发展而来，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Ext3</span><span style="font-family:'宋体';font-size:10.5pt;">文件系统带有日志功能，可以跟踪记录文件系统的变化，并将变化内容写入日志，写操作首先是对日志记录文件进行操作，若整个写操作由于某种原因</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> (</span><span
        style="font-family:'宋体';font-size:10.5pt;">如系统掉电</span><span
        style="font-family:'Calibri';font-size:10.5pt;">) </span><span style="font-family:'宋体';font-size:10.5pt;">而中断，系统重启时，会根据日志记录来恢复中断前的写操作，而且这个过程费时极短</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">目前</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Ext3</span><span style="font-family:'宋体';font-size:10.5pt;">文件系统已经非常稳定可靠</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">它完全兼容</span><span style="font-family:'Calibri';font-size:10.5pt;">Ext2</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件系统</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">用户可以平滑地过渡到一个日志功能健全的文件系统中来</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">这实际上了也是</span><span style="font-family:'Calibri';font-size:10.5pt;">ext3</span><span
        style="font-family:'宋体';font-size:10.5pt;">日志文件系统初始设计的初衷</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	Linux</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件系统在</span><span style="font-family:'Calibri';font-size:10.5pt;">windows</span><span
        style="font-family:'宋体';font-size:10.5pt;">中是不能识别的，但是在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">系统中你可以挂载的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">windows</span><span style="font-family:'宋体';font-size:10.5pt;">的文件系统，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">目前支持</span><span
        style="font-family:'Calibri';font-size:10.5pt;">MS-DOS</span><span
        style="font-family:'宋体';font-size:10.5pt;">，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">VFAT</span><span
        style="font-family:'宋体';font-size:10.5pt;">，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">FAT</span><span
        style="font-family:'宋体';font-size:10.5pt;">，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">BSD</span><span
        style="font-family:'宋体';font-size:10.5pt;">等格式</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">如果你使用的是</span><span style="font-family:'Calibri';font-size:10.5pt;">Redhat</span><span
        style="font-family:'宋体';font-size:10.5pt;">或者</span><span
        style="font-family:'Calibri';font-size:10.5pt;">CentOS</span><span style="font-family:'宋体';font-size:10.5pt;">，那么你不要妄图挂载</span><span
        style="font-family:'Calibri';font-size:10.5pt;">NFS</span><span style="font-family:'宋体';font-size:10.5pt;">格式的文件到</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">下，因为它不支持</span><span
        style="font-family:'Calibri';font-size:10.5pt;">NFS。</span><span style="font-family:'宋体';font-size:10.5pt;">虽然有些版本的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span
        style="font-family:'宋体';font-size:10.5pt;">支持</span><span
        style="font-family:'Calibri';font-size:10.5pt;">NFS</span><span style="font-family:'宋体';font-size:10.5pt;">，但不建议使用，因为目前的技术还不成熟</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	Ext3</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件系统为</span><span style="font-family:'Calibri';font-size:10.5pt;">Redhat/CentOS</span><span
        style="font-family:'宋体';font-size:10.5pt;">默认使用的文件系统，除了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Ext3</span><span style="font-family:'宋体';font-size:10.5pt;">文件系统外，有些</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">发行版例如</span><span
        style="font-family:'Calibri';font-size:10.5pt;">SuSE</span><span style="font-family:'宋体';font-size:10.5pt;">默认的文件系统为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">reiserFS </span><span
        style="font-family:'宋体';font-size:10.5pt;">，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Ext3 </span><span style="font-family:'宋体';font-size:10.5pt;">独特的优点就是易于转换，很容易在</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> Ext2 </span><span
        style="font-family:'宋体';font-size:10.5pt;">和</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> Ext3 </span><span style="font-family:'宋体';font-size:10.5pt;">之间相互转换，而具有良好的兼容性，其它优点</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> ReiserFS </span><span
        style="font-family:'宋体';font-size:10.5pt;">都有，而且还比它做得更好</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">如高效的磁盘空间利用和独特的搜寻方式都是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Ext3 </span><span style="font-family:'宋体';font-size:10.5pt;">所不具备的，速度上它也不能和</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> ReiserFS</span><span
        style="font-family:'宋体';font-size:10.5pt;">相媲美，在实际使用过程中，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">reiserFS </span><span
        style="font-family:'宋体';font-size:10.5pt;">也更加安全高效，据说反删除功能也不错</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	ReiserFS </span><span
        style="font-family:'宋体';font-size:10.5pt;">的优势在于，它是基于</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> B*Tree </span><span style="font-family:'宋体';font-size:10.5pt;">快速平衡树这种高效算法的文件系统，例如在处理小于</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> 1k </span><span
        style="font-family:'宋体';font-size:10.5pt;">的文件比</span><span style="font-family:'Calibri';font-size:10.5pt;"> Ext3 </span><span
        style="font-family:'宋体';font-size:10.5pt;">快</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> 10 </span><span
        style="font-family:'宋体';font-size:10.5pt;">倍</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">再一个就是</span><span style="font-family:'Calibri';font-size:10.5pt;"> ReiserFS </span><span
        style="font-family:'宋体';font-size:10.5pt;">空间浪费较少，它不会对一些小文件分配</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> inode</span><span style="font-family:'宋体';font-size:10.5pt;">，而是打包存放在同一个磁盘块</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> (</span><span
        style="font-family:'宋体';font-size:10.5pt;">簇</span><span
        style="font-family:'Calibri';font-size:10.5pt;">) </span><span
        style="font-family:'宋体';font-size:10.5pt;">中，</span><span style="font-family:'Calibri';font-size:10.5pt;">Ext2/Ext3 </span><span
        style="font-family:'宋体';font-size:10.5pt;">是把它们单独存放在不同的簇上，如簇大小为</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> 4k</span><span
        style="font-family:'宋体';font-size:10.5pt;">，那么</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> 2 </span><span
        style="font-family:'宋体';font-size:10.5pt;">个</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> 100 </span><span style="font-family:'宋体';font-size:10.5pt;">字节的文件会占用</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> 2 </span><span
        style="font-family:'宋体';font-size:10.5pt;">个簇，</span><span style="font-family:'Calibri';font-size:10.5pt;">ReiserFS </span><span
        style="font-family:'宋体';font-size:10.5pt;">则只占用一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">当然</span><span style="font-family:'Calibri';font-size:10.5pt;"> ReiserFS </span><span
        style="font-family:'宋体';font-size:10.5pt;">也有缺点，就是每升级一个版本，都要将磁盘重新格式化一次</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>【linux</b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>文件类型</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>】</b></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">在前面的内容中简单介绍了普通文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">(-)</span><span
        style="font-family:'宋体';font-size:10.5pt;">，目录</span><span
        style="font-family:'Calibri';font-size:10.5pt;">(d)</span><span
        style="font-family:'宋体';font-size:10.5pt;">等，在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">文件系统中，主要有以下几种类型的文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	1</span><span
        style="font-family:'宋体';font-size:10.5pt;">）正规文件（</span><span style="font-family:'Calibri';font-size:10.5pt;">regular file</span><span
        style="font-family:'宋体';font-size:10.5pt;">）：就是一般类型的文件，当用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">ls –l </span><span style="font-family:'宋体';font-size:10.5pt;">查看某个目录时，第一个属性为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”-“</span><span style="font-family:'宋体';font-size:10.5pt;">的文件就是正规文件，或者叫普通文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">正规文件又可分成纯文字文件（</span><span
        style="font-family:'Calibri';font-size:10.5pt;">ascii</span><span style="font-family:'宋体';font-size:10.5pt;">）和二进制文件（</span><span
        style="font-family:'Calibri';font-size:10.5pt;">binary</span><span
        style="font-family:'宋体';font-size:10.5pt;">）</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">纯文本文件是可以通过</span><span
        style="font-family:'Calibri';font-size:10.5pt;">cat, more, less</span><span
        style="font-family:'宋体';font-size:10.5pt;">等工具直接查看内容的，而二进制文件并不能</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">例如我们用的命令</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/bin/ls </span><span style="font-family:'宋体';font-size:10.5pt;">这就是一个二进制文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	2</span><span
        style="font-family:'宋体';font-size:10.5pt;">）目录（</span><span style="font-family:'Calibri';font-size:10.5pt;">directory</span><span
        style="font-family:'宋体';font-size:10.5pt;">）：这个很容易理解，就是目录，跟</span><span
        style="font-family:'Calibri';font-size:10.5pt;">windows</span><span style="font-family:'宋体';font-size:10.5pt;">下的文件夹一个意思，只不过在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">中我们不叫文件夹，而是叫做目录</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。ls –l </span><span style="font-family:'宋体';font-size:10.5pt;">查看第一个属性为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”d”。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	3</span><span
        style="font-family:'宋体';font-size:10.5pt;">）连接档（</span><span style="font-family:'Calibri';font-size:10.5pt;">link</span><span
        style="font-family:'宋体';font-size:10.5pt;">）：</span><span
        style="font-family:'Calibri';font-size:10.5pt;">ls –l </span><span style="font-family:'宋体';font-size:10.5pt;">查看第一个属性为</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> “l”</span><span
        style="font-family:'宋体';font-size:10.5pt;">，类似</span><span style="font-family:'Calibri';font-size:10.5pt;">windows</span><span
        style="font-family:'宋体';font-size:10.5pt;">下的快捷方式</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">这种文件在</span><span style="font-family:'Calibri';font-size:10.5pt;">linux</span><span
        style="font-family:'宋体';font-size:10.5pt;">中很常见，而且笔者在日常的系统运维工作中用的很多，所以你要特意留意一下这种类型的文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">在后续章节笔者会介绍</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	4</span><span
        style="font-family:'宋体';font-size:10.5pt;">）设备档（</span><span style="font-family:'Calibri';font-size:10.5pt;">device</span><span
        style="font-family:'宋体';font-size:10.5pt;">）：与系统周边相关的一些档案，通常都集中在</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> /dev </span><span style="font-family:'宋体';font-size:10.5pt;">这个目录之下！通常又分为两种：区块</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> (block) </span><span
        style="font-family:'宋体';font-size:10.5pt;">设备档</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span style="font-family:'宋体';font-size:10.5pt;">：就是一些储存数据，以提供系统存取的接口设备，简单的说就是硬盘啦！例如你的一号硬盘的代码是</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> /dev/hda1 </span><span
        style="font-family:'宋体';font-size:10.5pt;">等等的档案啦！第一个属性为</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> “ b “</span><span style="font-family:'宋体';font-size:10.5pt;">；字符</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> (character) </span><span
        style="font-family:'宋体';font-size:10.5pt;">设备档</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span style="font-family:'宋体';font-size:10.5pt;">：亦即是一些串行端口的接口设备，例如键盘</span><span
        style="font-family:'Calibri';font-size:10.5pt;">、</span><span style="font-family:'宋体';font-size:10.5pt;">鼠标等等！第一个属性为</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> “ c “。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	* linux </span><span
        style="font-family:'宋体';font-size:10.5pt;">文件后缀名</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">对于后缀名这个概念，相信你不陌生吧</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">系统中，文件的后缀名并没有具体意义，也就是说，你加或者不加，都无所谓</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">但是为了容易区分，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">爱好者们都习惯给文件加一个后缀名，这样当用户看到这个文件名时就会很快想到它到底是一个什么文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">例如</span><span style="font-family:'Calibri';font-size:10.5pt;">1.sh,  2.tar.gz,  my.cnf,  test.zip</span><span
        style="font-family:'宋体';font-size:10.5pt;">等等，如果你首次接触这些文件，你也许会感到很晕，没有关系，随着学习的深入，你就会逐渐的了解这些文件了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">笔者所列举的几个文件名中</span><span
        style="font-family:'Calibri';font-size:10.5pt;">1.sh</span><span style="font-family:'宋体';font-size:10.5pt;">代表它是一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">shell script </span><span
        style="font-family:'宋体';font-size:10.5pt;">，</span><span style="font-family:'Calibri';font-size:10.5pt;">2.tar.gz </span><span
        style="font-family:'宋体';font-size:10.5pt;">代表它是一个压缩包，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">my.cnf </span><span style="font-family:'宋体';font-size:10.5pt;">代表它是一个配置文件，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">test.zip </span><span
        style="font-family:'宋体';font-size:10.5pt;">代表它是一个压缩文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">另外需要你知道的是，早期</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Unix</span><span style="font-family:'宋体';font-size:10.5pt;">系统文件名最多允许</span><span
        style="font-family:'Calibri';font-size:10.5pt;">14</span><span style="font-family:'宋体';font-size:10.5pt;">个字符，而新的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Unix</span><span
        style="font-family:'宋体';font-size:10.5pt;">或者</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">系统中，文件名最长可以到达</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> 256 </span><span style="font-family:'宋体';font-size:10.5pt;">个字符！</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>【linux</b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>中的连接档</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>】</b></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">在讲连接档之前，需要你先理解</span><span
        style="font-family:'Calibri';font-size:10.5pt;">inode</span><span
        style="font-family:'宋体';font-size:10.5pt;">的概念</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">什么是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">inode</span><span style="font-family:'宋体';font-size:10.5pt;">呢？这就需要你知道磁盘的整体构造</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">磁盘是有多个盘片（类似与光盘）重叠在一起构成的，而每个盘片上会有一个可以移动的磁头，这个磁头的作用就是用来读写数据的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">磁头并不是一直在动，当磁头固定时，盘片转一圈，这一圈就是一个磁道了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">很多个盘片同半径的那一圈的磁道总和称为磁柱</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">而由圆心向外画出直线，可以得到一个个扇区，如图二所示，一个扇区的物理量大约是</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> 512 bytes ( </span><span
        style="font-family:'宋体';font-size:10.5pt;">约</span><span style="font-family:'Calibri';font-size:10.5pt;"> 0.5K )。</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_98.png">图一</span></p>
<p style="text-align: center;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_99.png"></span></p>
<p style="text-align: center;"><span style="font-family:'宋体';font-size:10.5pt;">图二</span></p>
<p style="text-align: justify;text-indent: 21pt;"><span style="font-family:'宋体';font-size:10.5pt;">知道了大体的硬盘构造之后，再来谈一谈怎么硬盘分割</span><span
        style="font-family:'Calibri';font-size:10.5pt;">( partition )</span><span
        style="font-family:'宋体';font-size:10.5pt;">呢？我们在进行硬盘分割的时候，最小都是以磁柱为单位进行分割的，那么分割完成之后自然就是格式化</span><span
        style="font-family:'Calibri';font-size:10.5pt;">( format )</span><span
        style="font-family:'宋体';font-size:10.5pt;">啰，在</span><span style="font-family:'Calibri';font-size:10.5pt;"> Linux </span><span
        style="font-family:'宋体';font-size:10.5pt;">里面我们在进行格式化的时候必须要考虑到</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> Block </span><span
        style="font-family:'宋体';font-size:10.5pt;">与</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> inode </span><span style="font-family:'宋体';font-size:10.5pt;">的信息，这个</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> block </span><span style="font-family:'宋体';font-size:10.5pt;">还好理解，他是我们磁盘可以记录的最小单位，是由数个</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> sector </span><span style="font-family:'宋体';font-size:10.5pt;">所组成的，所以他的大小通常为</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> n*512 bytes </span><span
        style="font-family:'宋体';font-size:10.5pt;">，例如</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> 4K 。</span><span
        style="font-family:'宋体';font-size:10.5pt;">那么</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> inode </span><span style="font-family:'宋体';font-size:10.5pt;">是什么？</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> Block </span><span style="font-family:'宋体';font-size:10.5pt;">是记录</span><span
        style="font-family:'Calibri';font-size:10.5pt;">“</span><span
        style="font-family:'宋体';font-size:10.5pt;">档案内容数据</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”</span><span
        style="font-family:'宋体';font-size:10.5pt;">的地区，而</span><span style="font-family:'Calibri';font-size:10.5pt;"> inode </span><span
        style="font-family:'宋体';font-size:10.5pt;">则是记录</span><span
        style="font-family:'Calibri';font-size:10.5pt;">“</span><span
        style="font-family:'宋体';font-size:10.5pt;">该档案的属性</span><span
        style="font-family:'Calibri';font-size:10.5pt;">、</span><span style="font-family:'宋体';font-size:10.5pt;">及该档案放置在哪一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> Block </span><span style="font-family:'宋体';font-size:10.5pt;">之内</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”</span><span style="font-family:'宋体';font-size:10.5pt;">的信息！所以，每个档案都会占用到至少一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> inode 。</span><span style="font-family:'宋体';font-size:10.5pt;">而当我们</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> Linux </span><span style="font-family:'宋体';font-size:10.5pt;">系统要找到这个档案时，他会先去搜寻</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> inode table </span><span
        style="font-family:'宋体';font-size:10.5pt;">找到这个档案的属性及数据放置的地区，然后再到数据去找到数据存放的</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> Block </span><span style="font-family:'宋体';font-size:10.5pt;">进而将数据取出利用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">这个</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> inode </span><span style="font-family:'宋体';font-size:10.5pt;">数目在一开始就会被设定好，他的设定方式通常是利用</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> ( </span><span
        style="font-family:'宋体';font-size:10.5pt;">硬盘大小</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> / </span><span
        style="font-family:'宋体';font-size:10.5pt;">一个容量</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> )</span><span style="font-family:'宋体';font-size:10.5pt;">，这个容量至少应该比</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> Block </span><span style="font-family:'宋体';font-size:10.5pt;">要大一些较佳，例如刚刚的</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> Block </span><span style="font-family:'宋体';font-size:10.5pt;">订为</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> 4K </span><span
        style="font-family:'宋体';font-size:10.5pt;">，那么</span><span style="font-family:'Calibri';font-size:10.5pt;"> inode </span><span
        style="font-family:'宋体';font-size:10.5pt;">可以订为</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> 8K </span><span
        style="font-family:'宋体';font-size:10.5pt;">左右</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">所以，一颗</span><span style="font-family:'Calibri';font-size:10.5pt;"> 1GB </span><span
        style="font-family:'宋体';font-size:10.5pt;">的硬盘，如果以</span><span style="font-family:'Calibri';font-size:10.5pt;"> 8K </span><span
        style="font-family:'宋体';font-size:10.5pt;">来规划他的</span><span style="font-family:'Calibri';font-size:10.5pt;"> inode </span><span
        style="font-family:'宋体';font-size:10.5pt;">数时，他的</span><span style="font-family:'Calibri';font-size:10.5pt;"> inode </span><span
        style="font-family:'宋体';font-size:10.5pt;">就会有</span><span style="font-family:'Calibri';font-size:10.5pt;"> 131072 </span><span
        style="font-family:'宋体';font-size:10.5pt;">个</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> inode </span><span style="font-family:'宋体';font-size:10.5pt;">啦！而一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> inode </span><span style="font-family:'宋体';font-size:10.5pt;">的大小为</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> 128 bytes </span><span
        style="font-family:'宋体';font-size:10.5pt;">这么大！这么一来的话，我们就可以清楚的知道了，那就是一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> partition </span><span
        style="font-family:'宋体';font-size:10.5pt;">格式化为一个</span><span style="font-family:'Calibri';font-size:10.5pt;"> filesystem </span><span
        style="font-family:'宋体';font-size:10.5pt;">之后，基本上，他一定会有</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> inode table </span><span
        style="font-family:'宋体';font-size:10.5pt;">与</span><span style="font-family:'Calibri';font-size:10.5pt;"> data area </span><span
        style="font-family:'宋体';font-size:10.5pt;">两个区块，一个用来记录档案的信息与该档案放置的</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> block </span><span style="font-family:'宋体';font-size:10.5pt;">区块，一个用来记录档案的内容！</span>
</p>
<p style="text-align: justify;text-indent: 21pt;"><span style="font-family:'宋体';font-size:10.5pt;">由于我们</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> Linux </span><span style="font-family:'宋体';font-size:10.5pt;">在读取数据的时候，是先查询</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> inode table </span><span
        style="font-family:'宋体';font-size:10.5pt;">以得到数据是放在那个</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> Block </span><span style="font-family:'宋体';font-size:10.5pt;">里面，然后再去该</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> Block </span><span style="font-family:'宋体';font-size:10.5pt;">里面读取真正的数据内容！然后，那个</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> block </span><span style="font-family:'宋体';font-size:10.5pt;">是我们在格式化硬盘的时候规定出来的一个值，这个</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> block </span><span style="font-family:'宋体';font-size:10.5pt;">是由</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> 2 </span><span
        style="font-family:'宋体';font-size:10.5pt;">的</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> n </span><span
        style="font-family:'宋体';font-size:10.5pt;">次方个</span><span style="font-family:'Calibri';font-size:10.5pt;">sector </span><span
        style="font-family:'宋体';font-size:10.5pt;">所集结而成的！所以，他是</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> 0.5K </span><span style="font-family:'宋体';font-size:10.5pt;">的倍数！假设我们</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> block </span><span style="font-family:'宋体';font-size:10.5pt;">规划为</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> 4KBytes </span><span
        style="font-family:'宋体';font-size:10.5pt;">好了，那么由于一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> inode </span><span style="font-family:'宋体';font-size:10.5pt;">与一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">block </span><span style="font-family:'宋体';font-size:10.5pt;">最多均只纪录一个档案，所以，如果你的一个档案有</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> 0.1 K bytes </span><span
        style="font-family:'宋体';font-size:10.5pt;">这么大时，你要晓得的是，由于你的</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> block </span><span
        style="font-family:'宋体';font-size:10.5pt;">为</span><span style="font-family:'Calibri';font-size:10.5pt;"> 4K bytes </span><span
        style="font-family:'宋体';font-size:10.5pt;">，因此，你就会有</span><span style="font-family:'Calibri';font-size:10.5pt;"> 3.9 Kbytes </span><span
        style="font-family:'宋体';font-size:10.5pt;">的空间浪费掉！所以，当你在格式化硬盘的时候，请千万注意到你的系统未来的使用方向</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>【ln </b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>建立连接档</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>】</b></span></p>
<p style="text-align: justify;text-indent: 21pt;"><span style="font-family:'宋体';font-size:10.5pt;">前面提到过两次连接档的概念，现在终于该好好介绍下这部分内容了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">连接档分为两种，硬连接（</span><span
        style="font-family:'Calibri';font-size:10.5pt;">hard  link</span><span
        style="font-family:'宋体';font-size:10.5pt;">）和软连接（</span><span style="font-family:'Calibri';font-size:10.5pt;">symbolic link</span><span
        style="font-family:'宋体';font-size:10.5pt;">）</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>Hard  Links</b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>：</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span style="font-family:'宋体';font-size:10.5pt;">上面内容中说过，当系统要读取一个文件时，就会先去读</span><span
        style="font-family:'Calibri';font-size:10.5pt;">inode table</span><span
        style="font-family:'宋体';font-size:10.5pt;">，然后再去根据</span><span style="font-family:'Calibri';font-size:10.5pt;">inode</span><span
        style="font-family:'宋体';font-size:10.5pt;">中的信息到块区域去将数据取出来</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">而</span><span style="font-family:'Calibri';font-size:10.5pt;">hard link </span><span
        style="font-family:'宋体';font-size:10.5pt;">是直接再建立一个</span><span style="font-family:'Calibri';font-size:10.5pt;">inode</span><span
        style="font-family:'宋体';font-size:10.5pt;">连接到文件放置的块区域</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">也就是说，进行</span><span style="font-family:'Calibri';font-size:10.5pt;">hard link</span><span
        style="font-family:'宋体';font-size:10.5pt;">的时候实际上该文件内容没有任何变化，只是增加了一个指到这个文件的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">inode</span><span style="font-family:'宋体';font-size:10.5pt;">，不过这样一来就会有个问题，因为增加的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">inode</span><span style="font-family:'宋体';font-size:10.5pt;">会连接到块区域，而目录本身仅仅消耗</span><span
        style="font-family:'Calibri';font-size:10.5pt;">inode</span><span style="font-family:'宋体';font-size:10.5pt;">而已，那么</span><span
        style="font-family:'Calibri';font-size:10.5pt;">hard link</span><span
        style="font-family:'宋体';font-size:10.5pt;">就不能连接目录了</span><span style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">请你记住，</span><span style="font-family:'Calibri';font-size:10.5pt;">hard link </span><span
        style="font-family:'宋体';font-size:10.5pt;">有两个限制：</span><span
        style="font-family:'Calibri';font-size:10.5pt;">1 </span><span style="font-family:'宋体';font-size:10.5pt;">不能跨文件系统，因为不通的文件系统有不同的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">inode table</span><span
        style="font-family:'宋体';font-size:10.5pt;">；</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> 2 </span><span style="font-family:'宋体';font-size:10.5pt;">不能连接目录</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><b>Symbolic Links</b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>：</b></span><span
        style="font-family:'宋体';font-size:10.5pt;">跟</span><span style="font-family:'Calibri';font-size:10.5pt;">hard link</span><span
        style="font-family:'宋体';font-size:10.5pt;">不同，这个是建立一个独立的文件，而这个文件的作用是当读取这个连接文件时，它会把读取的行为转发到该文件所</span><span
        style="font-family:'Calibri';font-size:10.5pt;">link</span><span
        style="font-family:'宋体';font-size:10.5pt;">的文件上</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">这样讲，也许比较绕口，那么就来举一个例子</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">现在有文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">a</span><span style="font-family:'宋体';font-size:10.5pt;">，我们做了一个软连接文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">b</span><span style="font-family:'宋体';font-size:10.5pt;">（只是一个连接文件，非常小），</span><span
        style="font-family:'Calibri';font-size:10.5pt;">b</span><span
        style="font-family:'宋体';font-size:10.5pt;">指向了文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">a。</span><span
        style="font-family:'宋体';font-size:10.5pt;">当读取</span><span
        style="font-family:'Calibri';font-size:10.5pt;">b</span><span
        style="font-family:'宋体';font-size:10.5pt;">时，那么</span><span
        style="font-family:'Calibri';font-size:10.5pt;">b</span><span style="font-family:'宋体';font-size:10.5pt;">就会把读取的动作转发到</span><span
        style="font-family:'Calibri';font-size:10.5pt;">a</span><span style="font-family:'宋体';font-size:10.5pt;">上，这样就读取到了文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">a。</span><span style="font-family:'宋体';font-size:10.5pt;">所以，当你删除文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">a</span><span
        style="font-family:'宋体';font-size:10.5pt;">时，文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">b</span><span style="font-family:'宋体';font-size:10.5pt;">并不会被删除，但是再读取</span><span
        style="font-family:'Calibri';font-size:10.5pt;">b</span><span style="font-family:'宋体';font-size:10.5pt;">时，会提示无法打开文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">而，当你删除</span><span
        style="font-family:'Calibri';font-size:10.5pt;">b</span><span
        style="font-family:'宋体';font-size:10.5pt;">时，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">a</span><span style="font-family:'宋体';font-size:10.5pt;">是不会有任何影响的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;text-indent: 21pt;"><span style="font-family:'宋体';font-size:10.5pt;">看样子，似乎</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> hard link </span><span
        style="font-family:'宋体';font-size:10.5pt;">比较安全，因为即使某一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> inode </span><span style="font-family:'宋体';font-size:10.5pt;">被杀掉了，只要有任何一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> inode </span><span style="font-family:'宋体';font-size:10.5pt;">存在，那么该文件就不会不见！不过，不幸的是，由于</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> Hard Link </span><span
        style="font-family:'宋体';font-size:10.5pt;">的限制太多了，包括无法做目录的</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> link </span><span style="font-family:'宋体';font-size:10.5pt;">，所以在用途上面是比较受限的！反而是</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> Symbolic Link </span><span
        style="font-family:'宋体';font-size:10.5pt;">的使用方向较广！那么如何建立软连接和硬连接呢？这就用到了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">ln </span><span
        style="font-family:'宋体';font-size:10.5pt;">命令</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;text-indent: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;">ln </span><span
        style="font-family:'宋体';font-size:10.5pt;">语法：</span><span style="font-family:'Calibri';font-size:10.5pt;">  ln [-s]  [</span><span
        style="font-family:'宋体';font-size:10.5pt;">来源文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">]  [</span><span
        style="font-family:'宋体';font-size:10.5pt;">目的文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">]</span></p>
<p style="text-align: justify;text-indent: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;">ln </span><span
        style="font-family:'宋体';font-size:10.5pt;">常用的选项就一个</span><span style="font-family:'Calibri';font-size:10.5pt;">-s </span><span
        style="font-family:'宋体';font-size:10.5pt;">，如果不加就是建立硬连接，加上就建立软连接</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_100.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">在建立硬连接前后，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">123</span><span style="font-family:'宋体';font-size:10.5pt;">目录所占空间大小并没有改变</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_101.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">当把源文件删除后，空间仍旧没有变化</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">说明了删除一个文件其实只是删除了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">inode</span><span
        style="font-family:'宋体';font-size:10.5pt;">信息</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_102.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">不能创建目录的硬连接</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_103.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">建立软连接后，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">456</span><span
        style="font-family:'宋体';font-size:10.5pt;">目录增加了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">4k</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_104.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">删除源文件后会提示</span><span
        style="font-family:'Calibri';font-size:10.5pt;">“</span><span
        style="font-family:'宋体';font-size:10.5pt;">没有这个文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”</span><span
        style="font-family:'宋体';font-size:10.5pt;">的错误</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_105.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">目录是可以软连接的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="6_106.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">删除软连接对源文件没有任何影响</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>

<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">上一页 <a
        href="5.htm">Linux系统的远程登录</a></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">下一页 <a
        href="7.htm">Linux系统用户以及用户组管理</a></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;"><a
        href="index.htm">回到主目录</a>&nbsp;</span></p>

</body>
</html>